【发布时间】:2013-02-08 13:56:28
【问题描述】:
我想统计失败的测试,并在所有测试完成后只失败一次。这些测试由 Jenkins 每晚运行,如果有失败或错误,会报告结果。 问题是我什至无法开始计数,因为这只有 failureProperty 和 errorProperty 可以为真或假,但是当它到达第一个失败或错误的测试时,它会停止并失败。我没有通过谷歌找到好的解决方案,他们向我推荐了这些属性,但它们没有满足我的需求。
代码如下:
<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" 参数不起作用。
如果您能帮助我,请提前感谢!
【问题讨论】:
-
哦,嘿,我刚刚找到了您的重复答案,这似乎有效。检查accepted answer here
-
我发现了问题所在。 errorProperty="test.failed" failureProperty="test.failed" 适用于 fail 我有更多的单元测试,所以脚本只能在第一个测试中幸存!我有点盲目,但这给了我一个想法。谢谢大家!
-
为了记录,我创建了一个全局变量,它是假的,如果测试失败,我切换到真。然后在我运行所有单独测试的地方,我调用了 fail ant 方法。
标签: java unit-testing ant jenkins