IEDA:单元测试无法显示覆盖率

IDEA:点击覆盖率运行,“无法附加测试报告到测试框架或测试框架意外退出

idea在作单元测试显示覆盖率时,明明测试通过,没问题,结果点击覆盖率执行便报错。下面是解决方法。

Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at com.intellij.rt.coverage.main.CoveragePremain.premain(CoveragePremain.java:35)
	at com.intellij.rt.coverage.main.CoveragePremain.premain(CoveragePremain.java:28)
	... 6 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
	at com.intellij.rt.coverage.instrumentation.Instrumentator.performPremain(Instrumentator.java:55)
	at com.intellij.rt.coverage.instrumentation.Instrumentator.premain(Instrumentator.java:33)
	... 12 more
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at ./open/src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 422

IEDA:单元测试无法显示覆盖率

解决方法:

点击idea 帮助—>编辑自定义VM选项(Help—>Edit Customer VM Option)
在打开的文件中的最后面加上

-Djava.io.tmpdir=D:\idea

(注意要另起一行)
D:\idea 是你电脑中的某个存在的目录(D:\idea这个只是个例子);

完成:

重启IDEA
IEDA:单元测试无法显示覆盖率
点击覆盖率执行,显示覆盖率。

上一篇:测试安排


下一篇:BigData之MongoDB:MongoDB基于分布式文件存储数据库的简介、下载、案例应用之详细攻略