Above answer to using -javaagent is correct. If you use maven, this is a bit complicated, so here is how I did it:
- Add the maven-dependency plugin so you can generate absolute dependency paths:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.5.1</version> <executions> <execution> <id>getClasspathFilenames</id> <goals> <goal>properties</goal> </goals> </execution> </executions> </plugin>
2. Add -javaagent to the surefire plugin
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.13</version> <configuration> <argLine>-javaagent:${com.googlecode.jmockit:jmockit:jar} -XX:-UseSplitVerifier</argLine> </configuration> </plugin>
3. In addition, you do not have to, but I would recommend using a relatively new version of jmockit. These problems were discovered in version 1.1 (@ Rogério fixed before September 2012, but adding -javaagent fixes it independently. For reference, I use the latest version available in maven central (2.5), as of this comment:
<dependency> <groupId>com.googlecode.jmockit</groupId> <artifactId>jmockit</artifactId> <version>1.5</version> <scope>test</scope> </dependency>
source share