我无法从我的build.xml
脚本中运行我的Junit测试。我觉得我已经尝试了一切。
这是我的build.xml
脚本。
<property file="build.properties"/>
<property name="src.dir" value="src"/>
<property name="build.dir" value="classes"/>
<property name="web.dir" value="war"/>
<property name="test.dir" value="test"/>
<path id="build.classpath">
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
<!-- servlet API classes: -->
<fileset dir="${appserver.lib}">
<include name="servlet*.jar"/>
</fileset>
<pathelement path="${build.dir}"/>
<pathelement path="${test.dir}"/>
</path>
<path id="classpath.base"/>
<path id="classpath.test">
<pathelement location="c:/ant/lib/junit.jar" />
<pathelement location="${build.dir}"/>
<pathelement location="${src.dir}"/>
<pathelement location="${test.dir}" />
<path refid="classpath.base" />
</path>
<target name="build">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" source="1.5" target="1.5" debug="true" deprecation="false" optimize="false" failonerror="true">
<src path="${src.dir}"/>
<classpath refid="build.classpath" source="1.5" target="1.5" debug="true" deprecation="false" optimize="false" failonerror="true"/>
</javac>
</target>
<target name="test">
<junit haltonfailure="true">
<classpath refid="classpath.test" />
<classpath refid="build.classpath"/>
<formatter type="brief" usefile="false" />
<test name="com.mmz.mvc.test.PracticeTest" />
</junit>
</target>
我从控制台收到以下错误消息。
test: [junit] Testsuite: com.mmz.mvc.test.PracticeTest [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec [junit] Null Test: Caused an ERROR [junit] com.mmz.mvc.test.PracticeTest [junit] java.lang.ClassNotFoundException: com.mmz.mvc.test.PracticeTest [junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:248) [junit] at java.lang.Class.forName0(Native Method) [junit] at java.lang.Class.forName(Class.java:247) [junit] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) [junit] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423) [junit] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137) BUILD FAILED C:\Users\Eric\Documents\Java\mmz\WEB-INF\build.xml:44: Test com.mmz.mvc.test.PracticeTest failed
答案 0 :(得分:1)
我想出了如何让它运行我的测试,但是现在告诉我我的测试是成功的,即使它应该失败,我知道它失败了因为我正在测试
assertTrue("Example doesnt work",false);