在eclipse中使用ant腳本、調用junit的task時會出現上述錯誤,解決方法:
1。將junit.jar 拷貝到eclipse的ant插件的目錄下的lib中
2。在eclipse->windows->ant->runtime中設置ant加載的jar,增加一個外部的jar,將
添加的junit.jar加入到ant的classpath中。
2009-03-12
現在遇到這個問題,按照上面作沒有用了,難道是jdk,junit.jar包和eclipse的版本沖突了?請知道的朋友告訴我一下。。。
Buildfile: E:\02_STUDY\07_Java\workspace\JunitTestProject\build.xml
clean:
[delete] Deleting directory E:\02_STUDY\07_Java\workspace\JunitTestProject\bin
[delete] Directory E:\02_STUDY\07_Java\workspace\JunitTestProject\report cannot be removed using the file attribute. Use dir instead.
copyxml:
[copy] Copying 10 files to E:\02_STUDY\07_Java\workspace\JunitTestProject\bin\testcases
compile:
[javac] Compiling 20 source files to E:\02_STUDY\07_Java\workspace\JunitTestProject\bin
[javac] 注意:E:\02_STUDY\07_Java\workspace\JunitTestProject\src\com\ustcsoft\struts1\action\SampleAction.java 使用或覆蓋了已過時的 API。
[javac] 注意:要了解詳細信息,請使用 -Xlint:deprecation 重新編譯。
jar:
[jar] Building jar: E:\02_STUDY\07_Java\workspace\JunitTestProject\dist\lib\JunitTestProject.jar
compiletests:
[javac] Compiling 14 source files to E:\02_STUDY\07_Java\workspace\JunitTestProject\bin\testcases
[javac] 注意:某些輸入文件使用或覆蓋了已過時的 API。
[javac] 注意:要了解詳細信息,請使用 -Xlint:deprecation 重新編譯。
[javac] 注意:E:\02_STUDY\07_Java\workspace\JunitTestProject\test\com\ustcsoft\struts2\action\ConfigTest.java 使用了未經檢查或不安全的操作。
[javac] 注意:要了解詳細信息,請使用 -Xlint:unchecked 重新編譯。
instrumented:
[cobertura-instrument] Cobertura 1.9.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[cobertura-instrument] Cobertura: Loaded information on 20 classes.
[cobertura-instrument] Instrumenting 20 files to E:\02_STUDY\07_Java\workspace\JunitTestProject\bin\instrumented-classes
[cobertura-instrument] Cobertura: Saved information on 20 classes.
[cobertura-instrument] Instrument time: 203ms
runtests:
[junit] Running com.ustcsoft.homework.logic.impl.HomeWorkLogicImplTest
[junit] java.lang.NoClassDefFoundError: org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner
[junit] Exception in thread "main"
BUILD FAILED
E:\02_STUDY\07_Java\workspace\JunitTestProject\build.xml:88: Test com.ustcsoft.homework.logic.impl.HomeWorkLogicImplTest failed
Total time: 3 seconds
快快樂樂、認認真真生活才是真。