Skip to content
Latchkey

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 output
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.

Terminal
vendor/bin/phpunit --list-tests
vendor/bin/phpunit --list-suites

Fix the testsuite and naming

  1. Point <testsuite> <directory> at the real test folder.
  2. Name files *Test.php and methods test* (or use the #[Test] attribute).
  3. Check --filter/--group are not deselecting everything.

Set an explicit configuration in CI

Terminal
vendor/bin/phpunit --configuration phpunit.xml --testsuite unit

How to prevent it

  • Define explicit <testsuite> paths in phpunit.xml.
  • Follow PHPUnit naming conventions for files, classes, and methods.
  • Treat "No tests executed!" as a signal that discovery broke, not noise.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →