MrSimonEmms
MrSimonEmms

Reputation: 1481

How do I run PHPUnit 3.7 with Ant?

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

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

    <target name="test">

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

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

    </target>

I've written a simple test that will fail and the ant test task is showing the failure in the [exec], but the build is marking as successful.

How do I configure the Ant task so that is can recognise when the test has failed?

Upvotes: 4

Views: 2253

Answers (1)

MrSimonEmms
MrSimonEmms

Reputation: 1481

Aaaaaaaah, that's how it's 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>

It now works a treat.

Upvotes: 3

Related Questions