Has anyone been able to get unit test coverage of both JMockit and Powermock unit tests running in JaCoCo from the Maven build?
I have an existing Powermock unit test suite that I would like to gradually migrate to JMockit. But I need to be able to see the test coverage of all unit tests in one report, preferably in Sonar.
I got the JMockit and Powermock tests together with Surefire / JaCoCo, putting JaCoCo in the "offline" mode (otherwise I had a problem when one of the agents was not completed at the end of the tests, and then mvn clean could not remove the generated target \ surefire \ surefirebooter2967126910681005991.jar in the next run). But for JMockit tests no coverage was created.
Please post some excerpts from your help if this works for you.
This is what my pom looks like (note that the surefire plugin is configured with reuseForks = false to bypass the PermGen memory leak in Powermock, this is one of the main reasons for switching to JMockit)
<profile> <id>sonar</id> <properties> <sonar.language>java</sonar.language> <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis> <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin> <sonar.java.codeCoveragePlugin>jacoco</sonar.java.codeCoveragePlugin> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.16</version> <configuration> <forkCount>1</forkCount> <reuseForks>false</reuseForks> <argLine>-XX:MaxPermSize=256m </argLine> <systemPropertyVariables> <jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile> </systemPropertyVariables> </configuration> </plugin> <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>
source share