代码之家  ›  专栏  ›  技术社区  ›  Grzenio

最后在蚂蚁中尝试

ant
  •  4
  • Grzenio  · 技术社区  · 14 年前

    在运行端到端集成测试的Ant脚本中,我首先启动一个进程,然后做一些其他的事情,然后运行测试,然后我需要确保终止该进程。但是,我需要确保即使失败了也要终止这个过程(所以我需要一个等价物来最终尝试)。推荐的方法是什么?

    1 回复  |  直到 14 年前
        1
  •  9
  •   Julien Hoarau    14 年前

    你可以使用 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>