I'm running a most basic task as follows:
<autoloader autoloaderpath="vendor/autoload.php">
<target name="asdf">
<echo msg="test"/>
<phpunit configuration="app/phpunit.xml"
haltonerror="true"
haltonfailure="true"
pharlocation="bin/phpunit"
/>
</target>
Now simply running this task:
phing -debug asdf
Will result in:
+Task: echo
-calling setter EchoTask::setMsg()
[echo] qwerqwer
+Task: phpunit
-calling setter PHPUnitTask::setConfiguration()
-calling setter PHPUnitTask::setHaltonerror()
-calling setter PHPUnitTask::setHaltonfailure()
-calling setter PHPUnitTask::setPharLocation()
#!/usr/bin/env php
Cannot open file "asdf.php".
Using the same configuration except pharlocation:
+Task: echo
-calling setter EchoTask::setMsg()
[echo] test
+Task: phpunit
-calling setter PHPUnitTask::setConfiguration()
-calling setter PHPUnitTask::setHaltonerror()
-calling setter PHPUnitTask::setHaltonfailure()
BUILD FINISHED
No errors, but the phpunit tasktype doesnt start.
Had a third simple variant that seemed fine, which resulted in 'phpunit: unrecognized option -- p' that i sadly cant reproduce..
I see you used PHPUnit 5.7. Did you use namespaces in your tests?
The current version of Phing is not compatible with namespaces like PHPUnit\Framework\TestCase
, you have to use the old class \PHPUnit_Framework_TestCase
instead.
The next Phing's release is going to be compatible with PHPUnit's namespaces (https://github.com/phingofficial/phing/issues/659). Meanwhile you can create phpunit.xml
and add this to build.xml
to run your tests:
<target name="phpunit" description="Run tests">
<exec executable="bin/phpunit" passthru="true">
<arg value="--configuration"/>
<arg value="app/phpunit.xml"/>
</exec>
</target>