关于异常:JMockit具有EclEmma代码覆盖问题

JMockit with EclEmma code coverage issue

在任何人否决我重复问题之前...。我已经阅读了与该主题相关的所有其他StackOverflow答案,但没有任何答案。

所以我正在使用JMockit 1.19,下面是我对Jmockit和Junit的pom.xml依赖关系

1
2
3
4
5
6
7
8
9
10
11
12
<dependency>
    <groupId>org.jmockit</groupId>
    jmockit</artifactId>
    <version>1.19</version>
</dependency>


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

我正在使用通过Eclipse Marketplace安装的EclEmma 2.3.2插件。

但是,当我尝试查看代码覆盖率时,会同时遇到几个不同的问题。

我得到以下异常日志:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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"

我还看到两个弹出式窗口……

1
2
3
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"

为了使JMockit成功运行,我提供了JVM参数

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

我认为这个论点与问题有关


好的,经过将近一个星期的工作并询问办公室中的所有人,我终于解决了这个问题。 我在构建路径上链接了另一个项目,这就是导致此问题的原因。 它不仅影响了这一点,而且还导致了JMockit,Mockito和PowerMock函数的大量问题。 在构建路径上链接项目将导致测试框架和代码覆盖范围的问题。