有没有人能够从Maven构建的JaCoCo中获得JMockit和Powermock单元测试的单元测试覆盖率?
我有一个Powermock单元测试的现有测试集,我想逐步迁移到JMockit.但我需要能够在一份报告中看到所有单元测试的测试覆盖率,最好是在Sonar中.
通过将JaCoCo置于"离线"模式,我确实让JMockit和Powermock测试与Surefire/JaCoCo一起运行(否则我遇到了一个问题,其中一个代理在测试结束时没有被终止,然后mvn clean无法删除在下次运行时生成目标\ surefire\surefirebooter2967126910681005991.jar).但是没有为JMockit测试生成覆盖范围.
如果你有这个工作,请发布你的pom的一些摘录.
这就是我的pom的样子(注意surefire插件与reuseForks = false一致,以解决Powermock中的PermGen内存泄漏问题,这是迁移到JMockit的主要原因之一)
<profile>
<!-- use this profile to perform Sonar analysis -->
<id>sonar</id>
<properties>
<sonar.language>java</sonar.language>
<!-- Tells Sonar to use the generated test coverage report -->
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<!-- Tells Sonar to use JaCoCo as the code coverage tool -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.java.codeCoveragePlugin>jacoco</sonar.java.codeCoveragePlugin>
</properties>
<build>
<plugins>
<!-- surefire (junit) plugin config with JaCoCo listener -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<!-- note: use single JVM to append …Run Code Online (Sandbox Code Playgroud)