Skip to content
Latchkey

PHPUnit "No tests executed!" - Fix Discovery & Config in CI

PHPUnit ran but discovered zero tests. The configured testsuite path matches no files, the filename suffix is not Test.php, or the test methods are not recognized as tests.

What this error means

PHPUnit finishes immediately with "No tests executed!" and exits - in newer versions this is a non-zero failure in CI. Nothing ran, so the suite is effectively unguarded.

PHPUnit output
PHPUnit 11.0.0 by Sebastian Bergmann and contributors.

No tests executed!

Common causes

Testsuite directory matches nothing

The <directory> in phpunit.xml points somewhere with no test files (wrong path, or tests live elsewhere in CI’s checkout), so discovery finds zero.

Wrong filename suffix or test markers

PHPUnit discovers files ending in Test.php and methods named test* or annotated #[Test]/@test. Files/methods that do not follow this are skipped.

How to fix it

Point the testsuite at the real directory

phpunit.xml
<!-- phpunit.xml -->
<testsuites>
  <testsuite name="unit">
    <directory suffix="Test.php">tests</directory>
  </testsuite>
</testsuites>

Name files and methods so they are discovered

  1. End test files in Test.php (e.g. OrderTest.php).
  2. Prefix methods with test or annotate them with #[Test] (PHPUnit 10+) / @test.
  3. Confirm the path by running phpunit --list-tests locally.

How to prevent it

  • Keep phpunit.xml testsuite paths in sync with the repo layout.
  • Follow the *Test.php / test* naming conventions.
  • Run phpunit --list-tests in CI as a sanity check.

Related guides

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