使用Junit 5运行测试时的java.lang.NoSuchMethodError
发布时间:2020-12-15 01:02:15 所属栏目:Java 来源:网络整理
导读:我创建了一个简单的测试来尝试Junit 5: import org.junit.jupiter.api.Test;public class MyTest { @Test public void testJupiter() { System.out.println("test"); }} 这是我使用的依赖: dependency groupIdorg.junit.jupiter/groupId artifactIdjunit-j
我创建了一个简单的测试来尝试Junit 5:
import org.junit.jupiter.api.Test; public class MyTest { @Test public void testJupiter() { System.out.println("test"); } } 这是我使用的依赖: <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.0.0</version> <scope>test</scope> </dependency> 堆栈跟踪是下一个: 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) 出了什么问题? 解决方法
我看到你使用IntelliJ,它只支持特定版本的jUnit5.
Junit5 – running tests in IntelliJ 尝试例如 <version>5.0.0-M4</version> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- java – 使用DialogInterface.OnClickListener区分单个Dial
- java引用jpython的方法示例
- 获取构造函数时的Java NoSuchMethodException
- java发送HttpClient请求及接收请求结果过程的简单实例
- Java Spring boot 2.0 跨域问题的解决
- “导入java.awt无法解析”和“*****无法解析为类型”
- 使用 Arrays.copyOf 进行数组复制
- java – 在servlet中首先调用destroy()还是finalize()?
- java – 如何避免对Base 64的警告?
- java – 1l for long,1f for float,1d for double,byte是什