Phing 和 PHPUnit,连最基本的东西都跑不起来 [英] Phing and PHPUnit, just cant get even the most basic thing running
问题描述
Using a composer-installed bin
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 a .phar
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.
Unrecognized option
Had a third simple variant that seemed fine, which resulted in 'phpunit: unrecognized option -- p' that i sadly cant reproduce..
Versions
- PU 5.7
- Phing 2.16
- PHP 7.1
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 PHPUnitFrameworkTestCase
, 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>
这篇关于Phing 和 PHPUnit,连最基本的东西都跑不起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!