当我尝试使用ant build脚本运行时,Junit正在抛出ClassNotFound异常。卡住!!
文件夹中有类文件,并且正确引用了库。
我的剧本:
<target name="run-junit-test" >
<mkdir dir="testReports" />
<junit printsummary="yes" haltonfailure="yes">
<classpath>
<pathelement location="WebContent/WEB-INF/classes" />
<pathelement location="src/tests" />
<pathelement location="WebContent/WEB-INF/lib/junit-4.11.jar" />
<pathelement location="WebContent/WEB-INF/lib/hamcrest-core-1.3.jar" />
<pathelement location="/opt/jdk1.6.0_35/jre/lib" />
</classpath>
<formatter type="plain" />
<formatter type="xml" />
<batchtest fork="yes" todir="testReports">
<fileset dir="src/tests">
<include name="**/*Test*.java" />
</fileset>
</batchtest>
</junit>
</target>
我正在获取错误:
Testsuite: TestJunit
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
Caused an ERROR
TestJunit
java.lang.ClassNotFoundException: TestJunit
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)