我对maven scoverage插件非常陌生,它是我工作的团队中首选的代码覆盖率工具。我正在尝试使用以下命令为测试覆盖率生成报告:
mvn scoverage:report它为我提供了一个详细的报告,显示了代码行和分支的类名和代码覆盖率,但没有显示单元测试没有覆盖哪些代码行/分支。
有没有一个带有scoverage的选项,我可以用来显示这些行,或者作为报告的一部分生成?
我试过用谷歌搜索,但没能找到任何对新闻报道有帮助的东西。
发布于 2021-02-19 06:52:44
所以我最终弄明白了,我所需要做的就是在插件部分中为我的pom文件的scoverage做一个小改动,并将突出显示设置为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>https://stackoverflow.com/questions/66074590
复制相似问题