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!
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).
Setting
failOnEmptyTestSuite="false"on the root<phpunit>element of myphpunit.xmlhas no effect when an explicit test selection (--filter,--group,--testsuite, or their--exclude-*counterparts) produces zero tests. PHPUnit exits with code1even though the XML configuration file explicitly configures it not to.Actual
Expected
Exit code
0, becausefailOnEmptyTestSuite="false"is explicitly set in the XML configuration. Using--do-not-fail-on-empty-test-suiteon the command line does produce exit code0, 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
ShellExitCodeCalculatorand 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).