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

穿精又带淫゛_ 提交于 2019-12-07 08:34:26

问题


I have an existing phpunit.xml (configuration file for phpunit), which 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 simply copy & paste content of phpunit.xml to my build.xml to run phpunit with the same configuration.

My target in build.xml for Phing looks like this:

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

Even that phpunit should automatically find phpunit.xml (when I launch it manually as like entering "phpunit" to my terminal and push 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 any way, how to reach described behaviour?


回答1:


It's possible since phing 2.4.13 with the configuration attribute:

<phpunit configuration="path/to/phpunit.xml"/>



回答2:


One of possible solutions would be

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

But it's missing the whole sugar around connection phpunit & phing.

I am afraid there are no other elegant solutions as the TestRunner is completely different in phing & phpunit.



来源:https://stackoverflow.com/questions/11824932/how-to-use-existing-phpunit-xml-in-phing-build-xml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!