我正在使用ant和TestNG 6.1.1,並且我的測試工作正常昨天很好。今天,當我嘗試運行測試時,我得到一個涉及com/beust/jcommander/ParamException的NoClassDefFoundError。下面是輸出:突然無法從ant運行TestNG測試([testng]引發:java.lang.ClassNotFoundException:com.beust.jcommander.ParameterException)
[copy] Copying 1 file to /Users/djohnson/src/webapp/components/build/tmp
[testng] Exception in thread "main" java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException
[testng] Caused by: java.lang.ClassNotFoundException: com.beust.jcommander.ParameterException
[testng] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[testng] at java.security.AccessController.doPrivileged(Native Method)
[testng] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[testng] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[testng] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[testng] at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[testng] The tests failed.
這裏是我使用的.xml文件:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Single Method Suite">
<test name="Single Method Test">
<classes>
<class name="DhcpTest">
<methods>
<exclude name=".*" />
<include name="setGetEnabledTest" />
</methods>
</class>
</classes>
</test>
</suite>
我還指定了完整的路徑,沒有運氣的類。我檢查過類路徑,一切似乎都很好,有沒有人有任何想法呢?
好了,所以我增加了jcommander-1.17.jar到類路徑中,我仍然得到同樣的錯誤。 – anotherdjohnson
現在我已經發布了這個讓全世界都可以看到的東西,我發現jcommander實際上並不在類路徑中。我確信我在那裏看到了它,但肯定它丟失了。 現在它無法找到測試,不知道爲什麼,因爲我已經三重檢查了類路徑,而且它絕對存在。 – anotherdjohnson