2013-04-22 37 views
4

我正在使用PHPUnit 3.7并尝试使用Apache Ant自动构建(并测试)我的项目。我已经通读了PHPUnit的文档,并且找不到如何配置它来向Ant抛出错误。如何使用Ant运行PHPUnit 3.7?

我现在的Ant任务看起来像这样(的测试文件所在的目录“测试”):

<target name="test"> 

     <echo message="Running unit tests with PHPUnit" /> 

     <exec executable="phpunit" > 
      <arg value="tests/"/> 
     </exec> 

    </target> 

我写了一个简单的测试,将失败,蚂蚁测试任务正显示出故障在[exec]中,但构建标记为成功。

如何配置Ant任务,以便在测试失败时能够识别?

回答

3

Aaaaaaaah,就是这么做的。 failonerror =“true”命令是我的朋友。

<target name="test"> 

     <echo message="Running unit tests with PHPUnit" /> 

     <exec executable="phpunit" failonerror="true"> 
      <arg value="tests/"/> 
     </exec> 

    </target> 

它现在工作的一种享受。