【问题标题】:Intellij IDEA code coverage doesn't workIntellij IDEA 代码覆盖率不起作用
【发布时间】:2014-01-03 15:30:39
【问题描述】:

当我尝试运行具有覆盖率的 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

有人可以帮忙解决吗?

【问题讨论】:

  • 这是特定于特定测试代码的吗?您的测试是否在未启用代码覆盖的情况下工作?
  • 我用不同的代码和不同的 Intellij 版本检查了它。我总是收到相同的结果。是的,测试在没有覆盖的情况下工作。
  • 您是否尝试过更改代码覆盖率运行程序?你能在这里发布代码覆盖率配置吗?
  • Anatoly,你能解决这个问题吗?我在使用 JaCoCo 进行 android 代码覆盖时遇到了同样的问题?

标签: java junit intellij-idea code-coverage


【解决方案1】:

看这里: https://youtrack.jetbrains.com/issue/IDEABKL-5941

您可以在idea的启动脚本中添加-Djava.io.tmpdir参数或替换TMP系统属性。

您可能还必须更改安装目录中idea.properties 中的idea.config.path 和idea.system.path。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-22
    • 1970-01-01
    • 2014-10-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多