下面是我的build.xml文件中的代码片段,当Beta目标失败时,它会重新运行相同的beta目标,但是在测试失败时控件不会进入重试逻辑,不知道我错过了什么这里
onLocationChanged
答案 0 :(得分:1)
<antcall>
有时会很有用,但它有a lot of pitfalls可能会使脚本难以推理。特别是,<antcall>
与Ant的正常依赖流冲突。
而不是<antcall>
,请考虑使用<target depends="...">
和<macrodef>
:
depends
的{{1}}属性启用条件逻辑。<target>
可以重复使用代码并减少代码重复。以下build.xml给出了一个示例:
<macrodef>
以下是上述Ant脚本的各种测试。它显示了脚本在各种故障情况下的行为......
<project name="ant-macrodef-retry" default="run">
<macrodef name="my-test-environment">
<attribute name="try"/>
<sequential>
<echo>Call test-environment here.</echo>
<!-- The following <condition> tasks are just for testing purposes. -->
<!-- The real <test-environment> would set these properties. -->
<condition property="integTest.failure" value="true">
<and>
<equals arg1="@{try}" arg2="1"/>
<isset property="failTry1"/>
</and>
</condition>
<condition property="rerunFailedTests.failure" value="true">
<and>
<equals arg1="@{try}" arg2="2"/>
<isset property="failTry2"/>
</and>
</condition>
</sequential>
</macrodef>
<target name="try1">
<my-test-environment try="1"/>
<echo message="integTest.failure = ${integTest.failure}" />
<condition property="failedTests">
<istrue value="${integTest.failure}" />
</condition>
</target>
<target name="try2" if="failedTests">
<echo message="Running Failed Integration Tests..." />
<my-test-environment try="2"/>
<echo message="rerunFailedTests.failure = ${rerunFailedTests.failure}" />
<fail message="Tests Failed on rerun">
<condition>
<istrue value="${rerunFailedTests.failure}" />
</condition>
</fail>
</target>
<target name="run" depends="try1,try2"/>
</project>