Maven ビルドから JaCoCo で動作する JMockit と Powermock の両方の単体テストの単体テスト カバレッジを取得できた人はいますか?
Powermock ユニット テストの既存のテスト セットがあり、徐々に JMockit に移行したいと考えています。しかし、できれば Sonar で、1 つのレポートですべての単体テストのテスト カバレッジを確認できる必要があります。
JaCoCo を「オフライン」モードにすることで、Surefire / JaCoCo と一緒に JMockit と Powermock のテストを実行できました (そうしないと、エージェントの 1 つがテストの最後に終了せず、mvn cleanで削除できないという問題がありました)。次回の実行時にtarget\surefire\surefirebooter2967126910681005991.jarが生成されます)。しかし、JMockit テストのカバレッジは生成されませんでした。
これが機能している場合は、pom からの抜粋を投稿してください。
これが私の pom の外観です (Powermock での PermGen メモリ リークを回避するために、surefire プラグインがreuseForks=falseで構成されていることに注意してください。これは、JMockit に移行する主な理由の 1 つです)。
<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>