试图通过IntelliJ Idea运行测试用例,但我得到了java.lang.nosuchmethoderror

时间:2017-11-03 10:00:47

标签: java unit-testing intellij-idea junit junit5

我正在尝试运行此文件,这是我为其中一个类编写的测试类。

当我尝试通过IntelliJ Idea运行时,我得不到java.lang.nosuchmethoderror,并且它不会为我运行测试,它将找不到测试方法。

错误是:

Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.getDefaultClassLoader()Ljava/lang/ClassLoader;
    at org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry.loadTestEngines(ServiceLoaderTestEngineRegistry.java:30)
    at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:53)
    at com.intellij.junit5.JUnit5IdeaTestRunner.createListeners(JUnit5IdeaTestRunner.java:39)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:49)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

这是我的测试类: https://pastebin.com/FMTwu3Rd

我认为有一些IntelliJ Idea设置错误,但我似乎无法找到它。 BTW测试是用JUnit 4运行的。

提前谢谢!

0 个答案:

没有答案
相关问题