views:

549

answers:

2

I am trying to use JMockit's code coverage abilities. Using the JVM parameter

-javaagent:jmockit.jar=coverage=.*MyClass.java:html::

I am able to run my tests (jmockit.jar and coverage.jar are on the classpath), unfortunately my log file says:

Loaded external tool: mockit.coverage.CodeCoverage=.*MyClass.java:html::
Loaded external tool: mockit.integration.junit3.JUnitTestCaseDecorator
Loaded external tool: mockit.integration.junit4.JUnit4ClassRunnerDecorator
Exception in thread "Thread-0" java.lang.NoClassDefFoundError
    at mockit.coverage.CodeCoverage$OutputFileGenerator.run(CodeCoverage.java:56)

...and no coverage file is generated. Has anyone gotten JMockit Coverage to work? If so, any thoughts as to what is causing this error? Thanks...

Answer: I needed to add coverage to the bootstrap entries rather than only the user entries (in the Eclipse run configuration)

Actual Answer The actual answer is that I was running the test with JUnit 3, but the coverage needs JUnit 4. That fixed things, and I didn't have to add any bootstrap entries.

+1  A: 

Random guess... Is coverage.jar on the classpath that jmockit uses - it might be a different one?

Chris Kimpton
Any idea how I can find out which classpath it's using and whether it is a different?
Epaga
+2  A: 

I was running the test with JUnit 3, but the coverage needs JUnit 4. That fixed things, and I didn't have to add any bootstrap entries.

Epaga