在运行端到端集成测试的Ant脚本中,我首先启动一个进程,然后做一些其他的事情,然后运行测试,然后我需要确保终止该进程。但是,我需要确保即使失败了也要终止这个过程(所以我需要一个等价物来最终尝试)。推荐的方法是什么?
你可以使用 Trycatch 任务从 Antcontrib
<trycatch property="error.message"> <try> <echo message="Run integration test..."/> <echo message="Start process"/> <antcall target="launchTests"/> </try> <catch> <echo message="Integration test failed"/> </catch> <finally> <echo message="Kill the process"/> <exec executable="kill -9 ..."/> </finally> </trycatch>