因此,我使用JUnit設置了自動迴歸測試,現在構建腳本設置爲調用TestSuite,它將一堆不同的測試打包到TestSuite中並返回它。Ant,JUnit和TestSuite
構建文件:
<target name="test-perform-check" depends="test-compile">
<junit printsummary="yes" fork="yes" haltonfailure="no">
<classpath path ="${mypath}" />
<jvmarg value="-Djava.ext.dirs=${extstar};${extpathextended};" />
<jvmarg value="-Dmipav=${mipav};" />
<sysproperty key="mipav" value="${mipav}"/>
<formatter type="xml"/>
<formatter type="plain" usefile="false"/>
<test name="test.JTest"/>
</junit>
</target>
JTest.java:
class JTest extends TestSuite {
public static Test suite() {
// set up a bunch of stuff
TestSuite suite = new TestSuite();
suite.addTest(new VolumeCompare());
suite.addTest(new VolumeCompare());
suite.addTest(new VolumeCompare());
suite.addTest(new FileExistence());
// do some other stuff
return suite;
}
}
輸出:
[junit] Testcase: null took 0.002 sec
[junit] FAILED
[junit] null
[junit] junit.framework.AssertionFailedError
[junit]
[junit] Testcase: null took 0 sec
[junit] FAILED
[junit] null
[junit] junit.framework.AssertionFailedError
[junit]
[junit] Testcase: null took 0.002 sec
[junit] FAILED
[junit] null
[junit] junit.framework.AssertionFailedError
[junit]
[junit] Testcase: null took 0 sec
[junit] FAILED
[junit] null
[junit] junit.framework.AssertionFailedError
[junit]
[junit] Test test.JTest FAILED
我的問題是 - 什麼,我需要在buildscript改變,使螞蟻運行測試正確嗎?
編輯:
VolumeCompare.java:
public class VolumeCompare extends TestCase {
public VolumeCompare (...) {
// ctor
}
@Test
public void testVolume() {
// this print statement is never reached
System.out.println("testing volume");
// compare volumes here
}
}
你可以發佈你的'VolumeCompare.java'文件嗎? –
已發佈。如果我設法修復它,我會把它扔在那裏。 – ellioth