Java JUnit测试未运行-返回“;“空测试套件”;
我只是想用Spring在JUnit中运行一个简单的get测试:Java JUnit测试未运行-返回“;“空测试套件”;,java,spring,maven,intellij-idea,junit,Java,Spring,Maven,Intellij Idea,Junit,我只是想用Spring在JUnit中运行一个简单的get测试: @RunWith(SpringJUnit4ClassRunner.class) public class ProfileTest { @Autowired ProfileDAO dao; @Test public void getProfileTest() { dao.getProfile("John Doe") } } 但是,每次我运行它时,它都会出现以下错误: Ex
@RunWith(SpringJUnit4ClassRunner.class)
public class ProfileTest {
@Autowired
ProfileDAO dao;
@Test
public void getProfileTest() {
dao.getProfile("John Doe")
}
}
但是,每次我运行它时,它都会出现以下错误:
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:31)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:42)
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:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Process finished with exit code 1
Empty test suite.
我尝试过使用文件-->使缓存无效/重新启动,但没有效果。根据进一步的研究,我认为这是由于junit jupiter api和junit commons命令之间的版本冲突造成的。有人能给我进一步的指导吗?我设法弄明白了。我从pom文件中删除了junit、junit jupiter api和junit commons命令的依赖项,然后只使用junit,如下所示:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
朱尼特
朱尼特
4.12
那么您使用的是JUnit4还是JUnit5?你的跑步者说“4”,但你的错误是“5”。