如何设置 Jacoco Gradle 中的最小代码覆盖率?
如果不满足,我希望构建失败。
最佳答案
该功能现已推出。您只需应用 Gradle JaCoCo 插件并定义覆盖率验证,如下所示:
apply plugin: 'jacoco'
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.7
}
}
}
}
// to run coverage verification during the build (and fail when appropriate)
check.dependsOn jacocoTestCoverageVerification
最后一行非常重要,因为除非您显式运行 jacocoTestCoverageVerification
任务,否则您的构建不会失败。
有关您可以添加的检查类型的更多信息,请参阅 documentation of the plugin .
关于gradle - Jacoco Gradle 中的最低代码覆盖率阈值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40649743/