Ant:设置phpunit.xml

时间:2012-07-24 12:57:08

标签: phpunit

在我的应用程序中,我在源代码旁边有phpunit测试。所以在旁边的所有地图中,让我们说DoSometing.class.php我有一个DoSomethingTest.class.php。

我想配置phpunit.xml来测试所有这些* Test.class.php文件。

我如何在phpunit.xml中执行此操作?

我现在有这样的事情:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit 
    backupGlobals="false"
    backupStaticAttributes="true"
    colors="true"
    convertErrorsToExceptions="true"
    convertNoticesToExceptions="true"
    convertWarningsToExceptions="true"
    processIsolation="true"
    stopOnFailure="true"
    syntaxCheck="false">
    <testsuites>
        <testsuite name="My Test Suite">
            <directory>./*Test.class.php</directory>
        </testsuite>
    </testsuites>
    <groups />
    <filter />
    <logging />
    <listeners />
</phpunit>

1 个答案:

答案 0 :(得分:2)

我们使用类似的结构,只有我们的测试文件以扩展名.TEST或.QTEST,.JTEST结束,基于测试框架,因为我们有JavaScript和其他需要测试的嵌入式代码。因此,我们在目录节点上使用后缀选项,如下所示。

<phpunit>
<testsuites>
    <testsuite name="Your Test Suite Name">
            <directory suffix=".test">.</directory>
    </testsuite>
</testsuites>
</phpunit>

对于PHP单元测试(* .TEST),我们使用以下PHPUNIT.xml(这是针对大小编辑的)

<!-- PHPUnit Core Settings -->
<phpunit backupStaticAttributes="false"
     bootstrap="PeriScope-Bootstrap.php"
             ...

    <testsuites>
        <testsuite name="ICAP User Interface Library">
            <directory suffix=".test">lib/.</directory>
        </testsuite>
        <testsuite name="Enterprise Scale Manager">
            <directory suffix=".test">ESM/.</directory>
        </testsuite>
        ...
    </testsuites>

<!-- Add files not covered with tests into Code Coverage Analysis -->
    <filter>
        <whitelist addUncoveredFilesFromWhitelist="true">
            <directory suffix=".class">lib/.</directory>
            <directory suffix=".fn">lib/.</directory>
            <directory suffix=".php">lib/.</directory>
            ...

            <exclude>
                <directory>ExternalLibraries</directory>
            </exclude>
        </whitelist>
    </filter>

    <logging>
        ...
    </logging>
</phpunit>
相关问题