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

Int*_*oot 7 phpunit

如果您配置了多个测试套件,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>
Run Code Online (Sandbox Code Playgroud)

例

phpunit --testsuite Unit|Integration 但不是 Acceptance

Ger*_*che 10

来自评论中的@emfi:自PHPUnit 6.0以来,已修复此问题以允许逗号单独的套件列表<pattern>.

资料来源:https://github.com/sebastianbergmann/phpunit/commit/80754cf323fe96003a2567f5e57404fddecff3bf


原始答案/ pre-PHPUnit 6.0

它不像你期望的那样工作.

--testsuite <name> Which testsuite to run.

哪里<pattern>不是实际模式.

您可以选择要运行的测试套件,但不能使用模式来过滤要运行的模式.

更好的描述 --testsuite <name> Which testsuite to run.

问题报告https://github.com/sebastianbergmann/phpunit/issues/2273

  • 实际上这个问题已经解决了(https://github.com/sebastianbergmann/phpunit/commit/80754cf323fe96003a2567f5e57404fddecff3bf).它现在通过用逗号分隔testuites来工作:`phpunit --testsuite suite1,suite2` (5认同)