最后在蚂蚁中尝试

Grz*_*nio 4 ant

在运行端到端集成测试的ant脚本中,我首先启动一个进程,然后执行其他一些操作,然后运行测试,然后我需要确保我终止进程.但是,我需要确保即使出现故障也会终止进程(因此我需要等效的最终尝试).这样做的推荐方法是什么?

Jul*_*rau 9

你可以使用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>
Run Code Online (Sandbox Code Playgroud)

  • 你不应该杀人-9.:) (2认同)