What is Junit trying to tell me when it throws a “

2019-06-28 08:52发布

I'm trying to run tests of the Apache POI project, but get the following exception. I saw it already a few times before, but every time I am completely lost about what JUnit is trying to tell me?

Javadoc just states "Thrown when a filter removes all tests from a runner. ", but this does not mean an Ant-filter, because it is thrown inside JUnit, so which Filter is possibly removing tests here? How do I debug/fix an Ant-file that gives me this message?

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:\workspaces\devtools\source\poi-trunk\junitvmwatcher937297744.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)

标签: ant junit
1条回答
劳资没心,怎么记你
2楼-- · 2019-06-28 09:34

After digging into this problem some more I found out that this is caused by running a newer Ant with an older JUnit. In this case it was Ant 1.7.1 and 1.8.2 against JUnit 3.8.1. Upgrading to JUnit 4.10 solved the problem!

查看更多
登录 后发表回答