jacoco测试代码覆盖率_使用Jacoco测量多模块Android项目中的单元测试覆盖率:第2部分

jacoco测试代码覆盖率

In the first article, we discovered one of the two key Gradle commands which come with Jacoco plugin — jacocoTestReport. As you now know, it can be used to measure code coverage in your project by generating detailed reports in HTML, XML, or CVS formats. This time I’d like to share my experience with the second piece of this puzzle — jacocoTestCoverageVerification.

第一篇文章中,我们发现了Jacoco插件随附的两个重要Gradle命令之一-jacocoTestReport 如您所知,它可以通过生成HTML,XML或CVS格式的详细报告来衡量项目中的代码覆盖率。 这次,我想与这个难题的第二部分( jacocoTestCoverageVerification)分享我的经验

As per the documentation, this task does the following:

根据文档,此任务执行以下操作:

Task for verifying code coverage metrics. Fails the task if violations are detected based on specified rules.

验证代码覆盖率指标的任务。 如果根据指定规则检测到违规,则使任务失败。

So as you might have already guessed, this tool can be used to check whether some coverage threshold is reached or not. Basically, you specify the minimum coverage measured in % and run the task. If your unit tests “visit” the desired % of your codebase then this task will silently complete. Otherwise, it will fail. This can be really helpful for development teams since it allows you to have a kind of enforcement for writing unit tests and all you need to do for that is to setup Jacoco and then simply ask your CI/CD to execute jacocoTestCoverageVerification along with other tasks for your pipelines.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值