Intellij IDEA代码覆盖率不起作用。

4
当我尝试使用测试覆盖率运行我的JUnit测试时,我收到以下错误:
FATAL ERROR in native method: processing of -javaagent failed
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:382)
    at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:397)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.coverage.main.CoveragePremain.premain(CoveragePremain.java:50)
    ... 6 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
    at com.intellij.rt.coverage.instrumentation.Instrumentator.premain(Instrumentator.java:40)
    ... 11 more
Exception in thread "main" 
Process finished with exit code 1

有人可以帮忙修复吗?


这是否特定于特定的测试代码?您的测试是否在未启用代码覆盖率的情况下工作? - Imran Saeed
我使用不同的代码片段和不同版本的Intellij进行了检查。我始终收到相同的结果。是的,测试可以在没有覆盖率的情况下工作。 - Anatoly
你尝试更改代码覆盖率运行器了吗?能否在这里发布代码覆盖率配置? - brevleq
Anatoly,你能解决这个问题吗?我在使用JaCoCo进行Android代码覆盖率时遇到了相同的问题。 - Diksha
1个回答

2
请看这里:https://youtrack.jetbrains.com/issue/IDEABKL-5941 您可以在Idea的启动脚本中添加-Djava.io.tmpdir参数,或替换TMP系统属性。
还可能需要在安装目录下的idea.properties中更改idea.config.path和idea.system.path。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接