簡體   English   中英

使用覆蓋率Intellij錯誤進行測試

[英]Test with Coverage Intellij Error

我可以運行所有測試,但它們均通過了,但是當我在覆蓋范圍內運行時,出現錯誤

FATAL ERROR in native method: processing of -javaagent 
failedjava.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:497)
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:497)
at 
com.intellij.rt.coverage.main.CoveragePremain.
premain(CoveragePremain.java:66)
... 6 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 4
at 

com.intellij.rt.coverage.instrumentation.Instrumentator.premain(Instrumentator.j ava:65)...還有11個

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

為什么沒有保險選項他們就通過了卻沒有保險呢? 我該如何解決呢?

underlying method引發異常時,將發生java.lang.reflect.InvocationTargetException 如果已使用reflection API invoked / call的if方法,則拋出異常。 並且反射API會將異常包裝到由基礎方法拋出的InvocationTargetException中。 要獲得更多了解,您可以參考下面的stackover flow鏈接。問題: user550413和許多Java專家回答。 我認為您可以在此鏈接上找到合適的答案。

什么會導致java.lang.reflect.InvocationTargetException?

就我而言,它是由Intellij路徑中的非ASCII字符引起的。 解決方案是在Intellij屬性中更改目錄:

解決方法:
將此行-Djava.io.tmpdir = C:\\ Temp添加到idea.exe.vmoptions文件(在C:\\ Program Files \\ ideaIU-11.1.4 \\ bin中)
並確保C:\\ Temp存在。

來源: https : //youtrack.jetbrains.com/issue/IDEABKL-5941#u=1401303711495

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM