单元测试-FATAL ERROR in native method: processing of -javaagent failed

文章目录

  • 前言
    • [单元测试-FATAL ERROR in native method: processing of -javaagent failed](#单元测试-FATAL ERROR in native method: processing of -javaagent failed)
      • [1. 报错信息](#1. 报错信息)
      • [2. 解决方案](#2. 解决方案)

前言

如果您觉得有用的话,记得给博主点个赞,评论,收藏一键三连啊,写作不易啊^ _ ^。

而且听说点赞的人每天的运气都不会太差,实在白嫖的话,那欢迎常来啊!!!


单元测试-FATAL ERROR in native method: processing of -javaagent failed

1. 报错信息

bash 复制代码
"C:\Program Files\Java\jdk1.8.0_211\bin\java.exe" -javaagent:C:\Users\杨镇宇\.IdeaIC2019.2\system\testAgent\intellij-coverage-agent-1.0.508.jar=C:\Users\杨镇宇\AppData\Local\Temp\coverageargs -Didea.test.cyclic.buffer.size=1048576 "-com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 com.yzy.demo.utils.HttpUtilTest
java.lang.reflect.InvocationTargetException
FATAL ERROR in native method: processing of -javaagent failed
	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:35)
	at com.intellij.rt.coverage.main.CoveragePremain.premain(CoveragePremain.java:28)
	... 6 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 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

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

2. 解决方案

加一行

bash 复制代码
-Djava.io.tmpdir=F:\tmp

tmp文件夹必须存在,F:\tmp是自己建的文件夹,名称无所谓,但是必须要有此文件夹。

-Djava.io.tmpdir=F:\tmp告诉 IntelliJ IDEA 在启动时将 F:\tmp作为临时文件存储目录,这样可以避免使用默认的临时目录。

重启idea

执行单侧测试类:

效果:

相关推荐
兮动人9 小时前
Java 单元测试中的 Mockito 使用详解与实战指南
java·开发语言·单元测试
安冬的码畜日常10 小时前
【JUnit实战3_01】第一章:JUnit 起步
测试工具·junit·单元测试
程序员二黑11 小时前
自动化测试入门:从零开始搭建你的第一个WebUI项目
单元测试·测试·ab测试
zhonghaoxincekj18 小时前
晶体管的定义,晶体管测量参数和参数测量仪器
功能测试·单片机·学习·测试工具·单元测试·制造
川石课堂软件测试1 天前
自动化测试之 Cucumber 工具
数据库·功能测试·网络协议·测试工具·mysql·单元测试·prometheus
执剑、天涯2 天前
通过一个typescript的小游戏,使用单元测试实战(二)
javascript·typescript·单元测试
啊森要自信2 天前
【GUI自动化测试】Python 自动化测试框架 pytest 全面指南:基础语法、核心特性(参数化 / Fixture)及项目实操
开发语言·python·ui·单元测试·pytest
川石课堂软件测试2 天前
MySQL数据库之DBA命令
数据库·网络协议·mysql·http·单元测试·prometheus·dba
lifewange3 天前
幂等机制
功能测试·单元测试
=>>漫反射=>>3 天前
单元测试 vs Main方法调试:何时使用哪种方式?
java·spring boot·单元测试