我正在尝试在一个包中运行一个简单的 junit。但它一直因 ClassNotFound Exception 而失败。我的构建文件如下所示:
<project name="JunitTest" default="test" basedir=".">
<property name="testdir" location="bin" />
<property name="full-compile" value="true" />
<path id="classpath.base"/>
<path id="classpath.test">
<pathelement location="lib/junit-4.10.jar" />
<pathelement location="${testdir}" />
<path refid="classpath.base" />
</path>
<target name="test">
<junit fork="no">
<classpath refid="classpath.test" />
<formatter type="brief" usefile="false" />
<test name="Test" />
</junit>
</target>
</project>
我的 Test.java 看起来像这样:
package com.org.test.data.mine.board;
import org.junit.Test;
public class Test {
@Test
public void testDummy() {
System.out.println("Hello");
}
}
这继续失败:
test:
[junit] Testsuite: Test
[junit] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec
[junit]
[junit] Null Test: Caused an ERROR
[junit] Test
[junit] java.lang.ClassNotFoundException: Test
[junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:274)
[junit]
[junit]
[junit] Test Test FAILED
我查看了其他 SO 帖子,但无法识别问题。帮助!!