Skip to content

failOnEmptyTestSuite="false" in phpunit.xml is ignored when --group/--filter/--testsuite matches no tests #6587

@sebastianbergmann

Description

@sebastianbergmann

Setting failOnEmptyTestSuite="false" on the root <phpunit> element of my phpunit.xml has no effect when an explicit test selection (--filter, --group, --testsuite, or their --exclude-* counterparts) produces zero tests. PHPUnit exits with code 1 even though the XML configuration file explicitly configures it not to.

Actual

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="phpunit.xsd"
         failOnEmptyTestSuite="false">
    <testsuites>
        <testsuite name="default">
            <directory>tests</directory>
        </testsuite>
    </testsuites>
</phpunit>
$ ./vendor/bin/phpunit --group doesNotExist
PHPUnit 12.5.19 by Sebastian Bergmann and contributors.

No tests executed!
$ echo $?
1

Expected

Exit code 0, because failOnEmptyTestSuite="false" is explicitly set in the XML configuration. Using --do-not-fail-on-empty-test-suite on the command line does produce exit code 0, so the CLI flag and the XML attribute behave inconsistently.

This is a side effect of the fix for #6276 (commit ae1cf4f), which introduced a new default of "fail on empty test suite" whenever explicit test selection is used. The new default is applied in ShellExitCodeCalculator and can only be overridden by the CLI flag --do-not-fail-on-empty-test-suite, not by the XML attribute. See also the discussion starting at #6584 (comment).

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions