我正在做一个小组项目,试图运行一个测试。运行时,我在文件中得到了错误沿着org.junit.platform.commons.util.PreconditionViolationException:无法加载名为的类...
我尝试过使缓存无效并重新启动,也尝试过重新导入pom.xml文件,但在尝试运行测试时仍然出现错误。
任何帮助都将不胜感激。
我正在使用IntelliJ IDEA 2019.2.4(社区版)
Intellij显示的错误
WARNING: TestEngine with ID 'junit-vintage' failed to discover tests
org.junit.platform.commons.util.PreconditionViolationException: Could not load class with name: <ommitted>
at org.junit.platform.engine.discovery.MethodSelector.lambda$lazyLoadJavaClass$0(MethodSelector.java:156)
at java.base/java.util.Optional.orElseThrow(Optional.java:408)
at org.junit.platform.engine.discovery.MethodSelector.lazyLoadJavaClass(MethodSelector.java:155)
at org.junit.platform.engine.discovery.MethodSelector.getJavaClass(MethodSelector.java:135)
at org.junit.vintage.engine.discovery.MethodSelectorResolver.resolve(MethodSelectorResolver.java:34)
at org.junit.vintage.engine.discovery.MethodSelectorResolver.lambda$resolve$0(MethodSelectorResolver.java:30)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
at org.junit.vintage.engine.discovery.MethodSelectorResolver.resolve(MethodSelectorResolver.java:30)
at org.junit.vintage.engine.discovery.VintageDiscoverer.collectTestClasses(VintageDiscoverer.java:64)
at org.junit.vintage.engine.discovery.VintageDiscoverer.discover(VintageDiscoverer.java:51)
at org.junit.vintage.engine.VintageTestEngine.discover(VintageTestEngine.java:61)
at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:168)
at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:155)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
1条答案
按热度按时间mnemlml81#
如果你不使用'junit-vintage'是最好从springboot依赖...在一些版本中,这个模块是不执行...为我解决。
请参阅此问题:spring-boot-starter-test with JUnit 5