How to use existing phpunit.xml in phing build.xml?

I have an existing phpunit.xml (configuration file for phpunit) that looks like this:

<phpunit backupGlobals="false" backupStaticAttributes="false" bootstrap="./tests/bootstrap.php" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" strict="true" verbose="true" colors="true"> <testsuites> <testsuite name="My Tests"> <directory>./tests</directory> </testsuite> </testsuites> </phpunit> 

As DRY says, I don't want to just copy and paste the contents of phpunit.xml into my build.xml to run phpunit with the same configuration.

My goal in build.xml for Phing is like this:

 <target name="unit-test"> <phpunit printsummary="true" /> </target> 

Even that phpunit should automatically find phpunit.xml (when I start it manually, like entering "phpunit" on my terminal and press enter, it works) and use it, in case of phing the output looks like this:

 [phpunit] Total tests run: 0, Failures: 0, Errors: 0, Incomplete: 0, Skipped: 0, Time elapsed: 0.00122 s 

So, is there a way how to achieve the described behavior?

+4
source share
2 answers

Maybe with phing 2.4.13 with attribute:

 <phpunit configuration="path/to/phpunit.xml"/> 
+9
source

One possible solution would be

 <exec command="phpunit" logoutput="/dev/stdout" /> 

But it skips all the sugar around the mix of phpunit and phing.

I am afraid that there are no other elegant solutions, as TestRunner is completely different from phing and phpunit .

+2
source

All Articles