2013-05-16 77 views
4

我試圖運行Apache POI項目的測試,但得到以下異常。我之前已經看過幾次,但是每次我完全失去了JUnit試圖告訴我的內容?什麼是Junit試圖告訴我它何時拋出「NoTestsRemainException」

Javadoc只是聲明「在過濾器從運行器中刪除所有測試時拋出」,但這並不意味着Ant過濾器,因爲它在JUnit內部拋出,所以哪個Filter可能在這裏刪除測試?如何調試/修復向我提供此消息的Ant文件?

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) 

回答

5

在深入研究這個問題後,我發現這是由於運行一個較舊的JUnit的Ant而導致的。在這種情況下,它是針對JUnit 3.8.1的Ant 1.7.1和1.8.2。升級到JUnit 4.10解決了這個問題!

相關問題