maven scoverage检查未被单元测试覆盖的行/分支



我对maven scoverage插件很陌生,这是我正在使用的团队中首选的代码覆盖工具。我正在尝试使用以下命令为测试覆盖率生成报告:

mvn scoverage:report

它给了我一个详细的报告,显示了类名和代码覆盖率,包括代码行和分支,但它没有显示哪些行/分支没有被单元测试覆盖。

是否有一个带有scoverage的选项,我可以使用它来显示这些行或作为报告的一部分生成?

我试着用谷歌搜索,但没有找到任何对scoverage有帮助的东西

所以最后我弄明白了,我所需要做的就是在插件部分做一个小改变,以覆盖我的pom文件,并将高亮设置为true

:

<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<minimumCoverage>80</minimumCoverage>
<failOnMinimumCoverage>true</failOnMinimumCoverage>
<aggregate>true</aggregate>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal> <!-- or integration-check -->
</goals>
<phase>prepare-package</phase> <!-- or any other phase -->
</execution>
</executions>
</plugin>

:后

<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<highlighting>true</highlighting>
<minimumCoverage>80</minimumCoverage>
<failOnMinimumCoverage>true</failOnMinimumCoverage>
<aggregate>true</aggregate>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal> <!-- or integration-check -->
</goals>
<phase>prepare-package</phase> <!-- or any other phase -->
</execution>
</executions>
</plugin>

最新更新