Mason
Mason

Reputation: 1762

JMockit with EclEmma code coverage issue

Before anyone downvotes me for a duplicate question.... I have read all the other StackOverflow answers related to this topic and nothing has answered my question.

So I am using JMockit 1.19, below is my pom.xml dependencies for Jmockit and Junit

<dependency>
    <groupId>org.jmockit</groupId>
    <artifactId>jmockit</artifactId>
    <version>1.19</version>
</dependency>


<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.7</version>
</dependency>

I am using EclEmma 2.3.2 plugin as installed via Eclipse Marketplace.

However I am getting several different issues at once when I try to view my code coverage.

For one I get the following exception log:

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
    at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.RuntimeException: Class java/util/UUID could not be instrumented.
    at org.jacoco.agent.rt.internal_9dd1198.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
    at org.jacoco.agent.rt.internal_9dd1198.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:99)
    at org.jacoco.agent.rt.internal_9dd1198.PreMain.createRuntime(PreMain.java:55)
    at org.jacoco.agent.rt.internal_9dd1198.PreMain.premain(PreMain.java:47)
    ... 6 more
Caused by: java.lang.NoSuchFieldException: $jacocoAccess
    at java.lang.Class.getField(Class.java:1695)
    at org.jacoco.agent.rt.internal_9dd1198.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:136)
    ... 9 more
FATAL ERROR in native method: processing of -javaagent failed
Exception in thread "main" 

I also get two pop-ups that say....

popup 1) - "No coverage data has been collected during this coverage session. Please do not terminate the Java process manually from Eclipse."

pupup 2) - "Error while dumping coverage data (code 5013).  com.mountainminds.eclemma.internal.core.launching.AgentServer"

In order to get JMockit to run successfully I am providing the JVM argument

-javaagent:C:/Users/vn90614/.m2/repository/org/jmockit/jmockit/1.19/jmockit-1.19.jar

I think this argument is realted to the issue

Upvotes: 1

Views: 1156

Answers (1)

Mason
Mason

Reputation: 1762

Ok, so I FINALLY solved this issue after almost a week of working on this and asking everyone in the office. I had linked another project on my build path and that's what caused this issue. Not only did it affect this but this caused a ton of issues with JMockit, Mockito, and PowerMock functions. Linking projects on your build path WILL cause issues for testing frameworks and code coverage.

Upvotes: 2

Related Questions