简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM