当前位置:首页 » 《我的小黑屋》 » 正文

Idea Junit运行 @Test 代码时出现 java.lang.reflect.InvocationTargetException 异常

23 人参与  2024年04月22日 17:14  分类 : 《我的小黑屋》  评论

点击全文阅读


问题

通过Idea运行@Test代码时出现如下问题:

java.lang.RuntimeException: java.lang.reflect.InvocationTargetExceptionat mockit.internal.startup.AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(AgentLoader.java:80)at mockit.internal.startup.AgentLoader.loadAgent(AgentLoader.java:52)at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:147)at org.junit.runner.Runner.<clinit>(Runner.java:22)at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:423)at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:36)at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:50)at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)Caused by: java.lang.reflect.InvocationTargetExceptionat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:423)at mockit.internal.startup.AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(AgentLoader.java:76)... 20 moreCaused by: java.lang.UnsatisfiedLinkError: sun.tools.attach.BsdVirtualMachine.createAttachFile(Ljava/lang/String;)Vat sun.tools.attach.BsdVirtualMachine.createAttachFile(Native Method)at sun.tools.attach.BsdVirtualMachine.<init>(BsdVirtualMachine.java:74)... 25 morejava.lang.RuntimeException: java.lang.reflect.InvocationTargetExceptionat mockit.internal.startup.AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(AgentLoader.java:80)at mockit.internal.startup.AgentLoader.loadAgent(AgentLoader.java:52)at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:147)at mockit.integration.junit4.JMockit.<clinit>(JMockit.java:21)at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:423)at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:36)at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:50)at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)Caused by: java.lang.reflect.InvocationTargetExceptionat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:423)at mockit.internal.startup.AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(AgentLoader.java:76)... 20 moreCaused by: java.lang.UnsatisfiedLinkError: sun.tools.attach.BsdVirtualMachine.createAttachFile(Ljava/lang/String;)Vat sun.tools.attach.BsdVirtualMachine.createAttachFile(Native Method)at sun.tools.attach.BsdVirtualMachine.<init>(BsdVirtualMachine.java:74)... 25 more

解决方案

我的问题是因为默认的jdk版本不是我本地安装的jdk,我将默认的jdk更换为项目中使用的jdk之后,就能够正常使用MockUp进行单元测试了,如果有遇到此类问题的可以试一下;
在这里插入图片描述


点击全文阅读


本文链接:http://m.zhangshiyu.com/post/98822.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最新文章

  • 《跟男友分手后,我成了他的白月光》程允川祝蓉蓉免费小说全文阅读_全本免费小说《跟男友分手后,我成了他的白月光》(程允川祝蓉蓉) -
  • 情散缘灭,你我绝然全章节(苏宸江雨柔)抖音热文_《情散缘灭,你我绝然全章节》最新章节免费在线阅读 -
  • 夜短梦未央全文阅读(夏琴韵顾越泽)最新热门小说_《夜短梦未央全文阅读》全集免费阅读 -
  • 孟晚森尹落月(等一个温晴暖冬热门小说)全文免费阅读无弹窗大结局_(孟晚森尹落月)等一个温晴暖冬热门小说免费阅读全文最新章节列表_笔趣阁(孟晚森尹落月) -
  • 寒夜孤灯对月明(裴行之沈卿璇)免费阅读 -
  • 你是我路过的四季全文阅读免费(傅清寒江宴婉)全文免费阅读无弹窗大结局_(你是我路过的四季全文阅读小说免费阅读)最新章节列表_笔趣阁(你是我路过的四季全文阅读) -
  • 雀登枝(邵麟锦明)小说完整版免费阅读_完结版免费小说雀登枝邵麟锦明 -
  • 《重生后,我踹掉夫君做女皇》沈洄崔青禾完结小说_完整版小说全文免费阅读《重生后,我踹掉夫君做女皇》沈洄崔青禾 -
  • 农门有喜:夫君别傲娇完整版小说,农门有喜:夫君别傲娇周景秀
  • 林知微时幸川小说在线免费阅读(错把真情付海棠无弹窗无删减)
  • 小说《一蓑烟雨春满城》免费阅读
  • 不原谅!虐师妹一时爽,全宗火葬场最新章节,不原谅!虐师妹一时爽,全宗火葬场免费阅读

    关于我们 | 我要投稿 | 免责申明

    Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1