2012-08-06 55 views
4

我有一个现有phpunit.xml(用于PHPUnit的配置文件),它看起来像这样:如何在phing build.xml中使用现有的phpunit.xml?

<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 

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

回答

2

一个可能的解决方案是

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

但它缺少连接周围的PHPUnit & phing整个糖。

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

+0

我downvoted这一点,不能撤消。 @Radek其实是对的。 https://www.phing.info/trac/ticket/1226应该使它成为可能。 – hbogert 2015-12-23 22:54:23