【问题标题】:How to use existing phpunit.xml in phing build.xml?如何在 phing build.xml 中使用现有的 phpunit.xml?
【发布时间】:2012-08-06 08:37:05
【问题描述】:

我有一个现有的 phpunit.xml(phpunit 的配置文件),如下所示:

<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 .

我在 build.xml 中的 Phing 目标如下所示:

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

即使 phpunit 应该自动找到 phpunit.xml(当我手动启动它时,就像在我的终端中输入“phpunit”并按回车一样,它可以工作)并使用它,在 phing 的情况下,输出如下所示:

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

那么有什么办法,如何达到所描述的行为?

【问题讨论】:

    标签: php phpunit phing


    【解决方案1】:

    since phing 2.4.13 可能带有configuration 属性:

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

    【讨论】:

      【解决方案2】:

      一种可能的解决方案是

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

      但它缺少连接 phpunit 和 phing 的全部内容。

      恐怕没有其他优雅的解决方案,因为 phingphpunit 中的 TestRunner 完全不同。

      【讨论】:

      • 我对此投了反对票,并且无法撤消。 @Radek 实际上是对的。 phing.info/trac/ticket/1226 应该让它成为可能。
      猜你喜欢
      • 2013-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-06
      • 1970-01-01
      • 2015-04-02
      • 2015-08-04
      相关资源
      最近更新 更多