我一直试图获得ant来执行一些用junit编写的测试。任何意见将不胜感激。我对蚂蚁和爪哇都很新,所以请耐心等待。当运行junit测试时发生ZipException
作为一个快速总结,我正在做的是试图让蚂蚁执行一个非常简单的测试,类路径看起来不错,考虑到蚂蚁调试的输出。我在类路径中明确提到了一个测试的类文件测试错误。此外,我收到一个ZipException,我不知道这是什么。
这里有一个测试用例我试图运行:
package testmanagment;
import junit.framework.*;
public abstract class EasyTest extends TestCase
{
public EasyTest(String name)
{
super(name);
}
protected void setUp()
{}
protected void testSeeMee() throws Exception
{
assertTrue(true);
}
protected void testSeeMeetoo() throws Exception
{
assertTrue(true);
}
}
有一个包中的一些测试,这一次只是看到为什么一切都失败。它以ZipException失败。
,这里是我的make文件的一点点:
<property name="src" value="src/"/>
<property name="build" value="build/"/>
<property name="test" value="${build}test/"/>
<property name="testreportsdir" value="${test}reports/"/>
<property name="classdir" value="${build}classes/"/>
<property name="lib" value="lib/"/>
<path id="files-classpath">
<fileset dir="lib/" >
<include name="*.jar"/>
</fileset>
</path>
<path id="tests-classpath">
<path refid="files-classpath"/>
<pathelement location="${classdir}/"/>
</path>
<path id="tests-runpath">
<path refid="tests-classpath"/>
<fileset dir="${test}/">
<include name="*.class"/>
<include name="**/*.class"/>
<include name="testmanagment/*.class"/>
<include name="*.*"/>
<include name="**/*.*"/>
<include name="testmanagment/*.*"/>
</fileset>
</path>
blah blah blah
<target name="test" depends="compile_tests">
<junit haltonfailure="true" printsummary="false">
<classpath refid="tests-runpath"/>
<formatter type="brief" usefile="false"/>
<test name="testmanagment.EasyTest"/>
<test name="testmanagment.TestUser"/>
<test name="testmanagment.TestTest"/>
</junit>
</target>
蚂蚁编译一切正常,并期待把一切都在正确的地方。但它似乎无法找到我的测试...这是一个蚂蚁吐出来的一小块,当我用-debug选项运行它时。
[junit] Using CLASSPATH /host/Users/Sheena/Desktop/School/Software dev/lab_project/lib/junit-4.8.1.jar:/host/Users/Sheena/Desktop/School/Software dev/lab_project/lib/sqlitejdbc-v056.jar:/host/Users/Sheena/Desktop/School/Software dev/lab_project/build/classes:/host/Users/Sheena/Desktop/School/Software dev/lab_project/build/test/testmanagment/EasyTest.class:/host/Users/Sheena/Desktop/School/Software dev/lab_project/build/test/testmanagment/TestTest.class:/host/Users/Sheena/Desktop/School/Software dev/lab_project/build/test/testmanagment/TestUser.class:/usr/share/ant/lib/junit.jar:/usr/share/java/ant-launcher-1.7.1.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar
Class org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter loaded from parent loader (parentFirst)
Finding class testmanagment.EasyTest
Ignoring Exception java.util.zip.ZipException: error in opening zip file reading resource testmanagment/EasyTest.class from /host/Users/Sheena/Desktop/School/Software dev/lab_project/build/test/testmanagment/EasyTest.class
Ignoring Exception java.util.zip.ZipException: error in opening zip file reading resource testmanagment/EasyTest.class from /host/Users/Sheena/Desktop/School/Software dev/lab_project/build/test/testmanagment/TestTest.class
Ignoring Exception java.util.zip.ZipException: error in opening zip file reading resource testmanagment/EasyTest.class from /host/Users/Sheena/Desktop/School/Software dev/lab_project/build/test/testmanagment/TestUser.class
[junit] Testsuite: testmanagment.EasyTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
[junit]
[junit] Null Test: Caused an ERROR
对于那里的丑陋输出感到抱歉,这是我现在需要处理的。
它看起来很像测试用例在类路径中,所以我不知道发生了什么......也许它的东西做的,但抛出:ZipException我不知道......
你使用什么工具?你是否在使用任何带ANT插件的IDE,例如Netbeans或Eclipse?如果路径错误,他们应该产生警告。 – Spoike 2011-05-18 11:24:29