问题描述
我有一个现有的 phpunit.xml (phpunit的配置文件),如下所示:
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>
正如 DRY 所说,我不想简单地复制&将 phpunit.xml 的内容粘贴到我的 build.xml 中,以相同的配置运行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.
我在 build.xml 中针对Phing的目标如下:
My target in build.xml for Phing looks like this:
<target name="unit-test">
<phpunit printsummary="true" />
</target>
即使phpunit应该自动找到phpunit.xml(当我像在终端上输入"phpunit"那样手动启动它并按Enter时,它也可以工作)并使用它,以防网络钓鱼,输出如下所示:
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?
推荐答案
It's possible since phing 2.4.13 with the configuration attribute:
<phpunit configuration="path/to/phpunit.xml"/>
这篇关于如何在phing build.xml中使用现有的phpunit.xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!