14

JMockit with Maven, Sonar, JaCoCo and Jenkins/Hudson

 3 years ago
source link: https://marco.dev/2012/10/09/jmockit-with-maven-sonar-jacoco-and-jenkinshudson/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

java-version.com: What's new in Java 16? 15? Keep up to date!

JMockit with Maven, Sonar, JaCoCo and Jenkins/Hudson

We deployed our fresh new tests based on JMockit in our Jenkins/Sonar environment and surprise … no unit test works anymore. Even the tests that don’t use JMockit (simple JUnit) stopped to work. It was strange that during the build phase with test there was no problem but in the Sonar test phase the first JUnit test looped permanently.

It took a while to figure out the problem.

There is an incompatibility between JaCoCo and JMockit.

To solve the issue we added the jmockit javaagent to the maven-surefire-plugin:

<argLine>-javaagent:"${settings.localRepository}"/com/googlecode/jmockit/jmockit/0.999.15/jmockit-0.999.15.jar</argLine>

Here how it looks like the plugin:

<plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-surefire-plugin</artifactId>
 <version>2.12</version>
 <configuration>
<argLine>-javaagent:"${settings.localRepository}"/com/googlecode/jmockit/jmockit/0.999.15/jmockit-0.999.15.jar</argLine>
 </configuration>
</plugin>

After this change the test are executed correctly and the incompatibility between JaCoCo and JMockit solved!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK