我试图运行Apache POI项目的测试,但得到以下异常。我以前已经看过几次了,但每次我都完全不知道JUnit想告诉我什么?
Javadoc只声明"当过滤器从运行器中删除所有测试时抛出"。,但这并不意味着是一个反过滤器,因为它是在JUnit内部抛出的,所以哪个过滤器可能在这里删除测试?我如何调试/修复一个反文件,给我这个消息?
test-main:
[junit] java.lang.NoClassDefFoundError: org/junit/runner/manipulation/NoTestsRemainException
[junit] at java.lang.Class.getDeclaredMethods0(Native Method)
[junit] at java.lang.Class.privateGetDeclaredMethods(Class.java:2451)
[junit] at java.lang.Class.getMethod0(Class.java:2694)
[junit] at java.lang.Class.getMethod(Class.java:1622)
[junit] at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
[junit] at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
[junit] Caused by: java.lang.ClassNotFoundException: org.junit.runner.manipulation.NoTestsRemainException
[junit] at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
[junit] at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[junit] at java.security.AccessController.doPrivileged(Native Method)
[junit] at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
[junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
[junit] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
[junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
[junit] ... 6 more
[junit] Exception in thread "main"
[junit] java.io.FileNotFoundException: C:workspacesdevtoolssourcepoi-trunkjunitvmwatcher937297744.properties (The system cannot find the file specified)
[junit] at java.io.FileInputStream.open(Native Method)
[junit] at java.io.FileInputStream.<init>(FileInputStream.java:138)
[junit] at java.io.FileReader.<init>(FileReader.java:72)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeAsForked(JUnitTask.java:1115)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:896)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:819)
[junit] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[junit] at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[junit] at java.lang.reflect.Method.invoke(Method.java:601)
[junit] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[junit] at org.apache.tools.ant.Task.perform(Task.java:348)
[junit] at org.apache.tools.ant.Target.execute(Target.java:357)
[junit] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[junit] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
[junit] at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
[junit] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[junit] at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
[junit] at org.apache.tools.ant.Main.runBuild(Main.java:758)
[junit] at org.apache.tools.ant.Main.startAnt(Main.java:217)
[junit] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
[junit] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
在深入研究这个问题之后,我发现这是由于使用较旧的JUnit运行较新的Ant造成的。在本例中,它是Ant 1.7.1和1.8.2对JUnit 3.8.1。升级到JUnit 4.10解决了这个问题!