PHPUnit "No tests executed!" - Fix Empty Test Runs in CI
PHPUnit found zero tests to run. A run that tests nothing should not look green, so this is worth treating as a failure - usually discovery is pointed at the wrong directory or your class/method names don’t match the conventions.
What this error means
PHPUnit prints "No tests executed!" (or "No tests found in directory"), exits, and your suite quietly does nothing. Your tests exist, but PHPUnit discovered none from the configured testsuite.
PHPUnit 11.2.0 by Sebastian Bergmann and contributors.
No tests executed!Common causes
Testsuite path is wrong
The <testsuite> <directory> in phpunit.xml (or the path passed on the CLI) points where no tests live, so nothing is collected.
Tests don’t match naming conventions
PHPUnit discovers files ending in Test.php and methods named test* or annotated #[Test]. Misnamed classes/methods are invisible.
A --filter or --group selected nothing
A --filter/--group expression, or <groups> config, can deselect every test, leaving zero executed.
How to fix it
List what PHPUnit discovers
Confirm which tests are visible without running them.
vendor/bin/phpunit --list-tests
vendor/bin/phpunit --list-suitesFix the testsuite and naming
- Point
<testsuite><directory>at the real test folder. - Name files
*Test.phpand methodstest*(or use the#[Test]attribute). - Check
--filter/--groupare not deselecting everything.
Set an explicit configuration in CI
vendor/bin/phpunit --configuration phpunit.xml --testsuite unitHow to prevent it
- Define explicit
<testsuite>paths inphpunit.xml. - Follow PHPUnit naming conventions for files, classes, and methods.
- Treat "No tests executed!" as a signal that discovery broke, not noise.