How to run PHPUnit 3.7 using Ant?

I am using PHPUnit 3.7 and trying to automatically build (and test) my project with Apache Ant. I read the documentation for PHPUnit and cannot find how to configure it to throw errors to Ant.

The current Ant task looks like this (test files are in the "tests" directory):

<target name="test"> <echo message="Running unit tests with PHPUnit" /> <exec executable="phpunit" > <arg value="tests/"/> </exec> </target> 

I wrote a simple test that will fail, and the Ant test task will fail in [exec], but the assembly will be marked as successful.

How do I configure an Ant task so that it can recognize when a test fails?

+4
source share
1 answer

Ahhhh, how it was done. The failonerror = "true" command is my friend.

  <target name="test"> <echo message="Running unit tests with PHPUnit" /> <exec executable="phpunit" failonerror="true"> <arg value="tests/"/> </exec> </target> 

Now it works.

+3
source

All Articles