如何在命令行中运行多个PHPUnit测试套件?

13

如果你在phpunit.xml中设置了多个测试套件,如何从命令行运行多个测试套件中的部分而不是全部测试套件?

phpunit.xml

<?xml version="1.0" encoding="utf-8"?>
<phpunit
    backupGlobals="false"
    backupStaticAttributes="false"
    colors="true"
    convertErrorsToExceptions="true"
    convertNoticesToExceptions="true"
    convertWarningsToExceptions="true"
    processIsolation="false"
    stopOnFailure="true"
    syntaxCheck="true"
    bootstrap="tests/bootstrap.php">
        <testsuites>
            <testsuite name="Unit">
                <directory suffix="Test.php">tests/unit</directory>
            </testsuite>
            <testsuite name="Integration">
                <directory suffix="Test.php">tests/integration</directory>
            </testsuite>
            <testsuite name="Acceptance">
                <directory suffix="Test.php">tests/acceptance</directory>
            </testsuite>
        </testsuites>
        <logging>
            <log type="coverage-html" target="build/coverage"/>
            <log type="testdox-html" target="build/requirements.html"/>
        </logging>
        <filter>
            <whitelist>
                <directory suffix=".php">src</directory>
            </whitelist>
        </filter>
</phpunit>

例子

phpunit --testsuite Unit|Integration,但不包括Acceptance

1个回答

20
自 PHPUnit 6.0 开始,您可以指定一个逗号分隔的套件列表:
--testsuite suite1,suite2

PHPUnit 6.0及以下版本的原始答案

它不能像你期望的那样工作,即(其中<pattern>不是实际的模式):

--testsuite <pattern> Filter which testsuite to run.

你可以选择要运行的测试套件,但不能使用模式来过滤要运行的测试套件。
更好的描述是--testsuite <name>,用于指定要运行的测试套件。
问题报告请参见https://github.com/sebastianbergmann/phpunit/issues/2273,该问题已在6.0版本中修复

6
问题已经解决了(https://github.com/sebastianbergmann/phpunit/commit/80754cf323fe96003a2567f5e57404fddecff3bf)。现在可以通过逗号分隔测试套件来使用它,例如: phpunit --testsuite suite1,suite2 - emfi

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接