是否有人能够从Maven构建中获得在JaCoCo中工作的JMockit和Powermock单元测试的单元测试覆盖率?Powermock和JMockit单元测试的测试覆盖率
我有一个Powermock单元测试的现有测试集,我想逐步迁移到JMockit。但我需要能够在一份报告中看到所有单元测试的测试覆盖率,最好是在Sonar中。
我确实通过将JaCoCo置于“脱机”模式中,将JMockit和Powermock测试与Surefire/JaCoCo一起运行(否则,我有一个问题,其中一个代理未在测试结束时被终止,然后mvn clean无法删除生成的target \ surefire \ surefirebooter2967126910681005991.jar下次运行)。但是没有为JMockit测试生成覆盖率。
如果你有这个工作,请张贴你的朋友的一些摘录。
这是我的聚甲醛是什么样子(注意万无一失插件congigured与reuseForks =假要解决在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 to JaCoCo coverage file -->
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<argLine>-XX:MaxPermSize=256m </argLine>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>
<!-- JaCoCo (Sonar) plugin config-->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.3.201306030806</version>
<executions>
<execution>
<id>instrument</id>
<phase>process-classes</phase>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>restore</id>
<phase>site</phase>
<goals>
<goal>restore-instrumented-classes</goal>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.0</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
<configuration>
<append>true</append>
</configuration>
</plugin>
</plugins>
</build>
</profile>