我想计算失败的测试,并在所有测试完成时只失败一次。这些测试由 Jenkins 每晚运行,并在出现故障或错误时报告结果。 问题是我什至无法开始计数,因为它只有 failureProperty 和 errorProperty,可以是 true 或 false,但是当它到达第一个失败或错误的测试时,它会停止并失败。我没有找到谷歌的好解决方案,他们向我推荐了这些属性,但他们没有满足我的需要。
代码如下:
<junit printsummary="true" fork="yes" forkmode="once"
showoutput="false" haltonfailure="no" maxmemory="1024m"
errorProperty="test.failed" failureProperty="test.failed">
<classpath refid="junit.classpath" />
<batchtest fork="yes" todir="${junit.dir}/raw" >
<formatter type="xml" />
<fileset dir="${classes.dir}">
<include name="**/*Test.class" />
<exclude name="*ear*/**"/>
<exclude name="**/Base*.class" />
<exclude name="**/JNDI*.class" />
</fileset>
</batchtest>
</junit>
<fail message="At least one test failed or has errors, please check test results in Jenkins to see details!" if="test.failed" />
我是否错过了重要的事情?在这种情况下,haltonfailure="no" 参数似乎不起作用。
如果您能帮助我,在此先感谢您!
最佳答案
您需要使用 ant 的 junitreport
生成报告。这会输出一个 xml 文件,jenkins 会很好地为您计算和显示该文件,如果您有兴趣,还会显示演化图等。
关于java - ANT Jenkins 单元测试 - 计算失败的测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14774143/