我正在使用类似这样的目标通过Ant运行JUnit:
<target name="junit" depends="compile">
<mkdir dir="${report.dir}"/>
<junit printsummary="yes" haltonfailure="yes" showoutput="yes" >
<classpath>
<path refid="classpath"/>
<path location="${classes.dir}"/>
</classpath>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="${report.dir}">
<fileset dir="${src.dir}" includes="**/*Tests.java" />
</batchtest>
</junit>
</target>
Run Code Online (Sandbox Code Playgroud)
我有一个这样的课:
public class UserTests extends TestCase {
public void testWillAlwaysFail() {
fail("An error message");
}
public void testWillAlwaysFail2() {
fail("An error message2");
}
}
Run Code Online (Sandbox Code Playgroud)
haltonfailure="yes"一旦单个测试失败,似乎导致构建停止,仅记录第一个失败的测试.将其设置为"off"会导致整个构建成功(即使测试失败消息写入输出).
我希望它运行所有测试(即使一个失败),然后在任何测试失败时停止构建.
是否有可能做到这一点?
mar*_*ton 41
您可以设置任务的failureproperty属性junit,然后使用任务测试属性fail:
<junit haltonfailure="no" failureproperty="test.failed" ... >
...
</junit>
<fail message="Test failure detected, check test results." if="test.failed" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9628 次 |
| 最近记录: |