是否有任何Java测试框架(最好是Jacoco和/或Sonar)允许代码覆盖率较差的团队原谅现有的代码库,但要求新代码高于阈值,(直到他们可以获得所有旧代码)盖的!)
您可以在pom中添加构建插件。这个是进行线覆盖检查至少80%。有关更多信息,请参阅Jacoco doc。
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>jacoco-check</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.80</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我希望您可以使用Sonar Quality Gates并将其与CI服务器集成。在詹金斯,你可能想尝试Quality Gates Plugin。