如何在Java中检查测试覆盖率?

时间:2018-07-22 17:05:09

标签: java intellij-idea code-coverage

我要检查测试覆盖率,并通过运行Test in'lesson_3进行覆盖率测试。我收到错误消息:

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:498)
    at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
    at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: 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:498)
    at com.intellij.rt.coverage.main.CoveragePremain.premain(CoveragePremain.java:66)
    ... 6 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
    at com.intellij.rt.coverage.instrumentation.Instrumentator.premain(Instrumentator.java:64)
    ... 11 more
FATAL ERROR in native method: processing of -javaagent failed

Process finished with exit code 1
Exception in thread "main"  

1 个答案:

答案 0 :(得分:1)

基于堆栈跟踪,您会受到IDEA-177038的影响,该标记为IDEABKL-5941的副本。

已知的解决方法是在命令行参数中添加以下内容:

-Djava.io.tmpdir=C:\Temp