ClassNotFoundException:运行JUnit5时org.junit.platform.launcher.TestExecutionListener

时间:2018-07-13 10:16:11

标签: spring-boot gradle intellij-idea junit junit5

在我基于Intelly Idea的Gradle的项目(Java Spring Boot版本'2.0.3.RELEASE')中,当我尝试调试单元测试时,出现此错误:

function processResults(results, status, pagination) {
   var photo_reference = results[0].photos[0].getUrl({maxWidth: 1000}).replace(/[^?]+\?(1s)?([0-9a-zA-Z-_]+)(\&.+)?/, '$2');
}

Gradle版本为4.8

等级依赖是:

Exception in thread "main" java.lang.NoClassDefFoundError: org/junit/platform/launcher/TestExecutionListener
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
  at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  at com.intellij.junit5.JUnit5IdeaTestRunner.createListeners(JUnit5IdeaTestRunner.java:39)
  at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:45)
  at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
  at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.ClassNotFoundException: org.junit.platform.launcher.TestExecutionListener
  at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  ... 16 more

我缺少什么设置?如何解决此问题?

1 个答案:

答案 0 :(得分:0)

尝试运行

gradle test 

在命令行上。这应该显示更多详细的输出,以帮助诊断问题。