MavenビルドからJaCoCoで動作するJMockitとPowermockユニットテストのユニットテストカバレッジを取得できた人はいますか?PowermockとJMockitユニットテストのテストカバレッジ
私は、Powermockユニットテストの既存のテストセットを持っています。徐々にJMockitに移行したいと思います。しかし、私はすべての単体テストのテストカバレッジを1つのレポート、好ましくはSonarで見ることができる必要があります。
JaCoCoを「オフライン」モードにすることで、私はSurefire/JaCoCoと一緒にJMockitとPowermockのテストを実行しました(そうでないと、テストの最後にエージェントの1つが終了せず、次にmvnは、次の実行時にターゲット\ surefire \ surefirebooter2967126910681005991.jarを削除できませんでした。しかし、JMockitテストの対象範囲は生成されませんでした。
あなたがこの作業をしている場合、あなたのポームからいくつかの抜粋を投稿してください。
これは私のポンポンは以下のように(確実なプラグインを注意がPowermockでPermGenメモリリークを回避するためにreuseForks = falseをでcongiguredされ、これは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>