如何检查所有类已在Gradle中测试过

时间:2017-07-24 22:13:30

标签: java unit-testing gradle jacoco

我正在使用带有jacoco插件的Gradle,我正在寻找一种方法来检查项目的所有类在单元测试和至少一半的指令中进行测试。

1 个答案:

答案 0 :(得分:1)

这是我找到的解决方案

// apply plugin
apply "jacoco"

jacocoTestCoverageVerification {
        violationRules {
            rule {
                // this rule insure 50% of instructions have been tested 
                limit {
                    minimum = 0.5
                }
            }
            rule {
                // this rule insure all classes have been tested
                limit {
                    counter = 'CLASS'
                    value = 'MISSEDCOUNT'
                    maximum = 0                 
                }
            }       
        }
}