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
- End test files in
Test.php(e.g.OrderTest.php). - Prefix methods with
testor annotate them with#[Test](PHPUnit 10+) /@test. - Confirm the path by running
phpunit --list-testslocally.
How to prevent it
- Keep
phpunit.xmltestsuite paths in sync with the repo layout. - Follow the
*Test.php/test*naming conventions. - Run
phpunit --list-testsin CI as a sanity check.
Related guides
PHPUnit "Error: Class ... not found" - Fix Autoloading in CIFix PHPUnit "Error: Class ... not found" in CI - Composer autoload not regenerated, a PSR-4 namespace/path mi…
RSpec "NameError: uninitialized constant" - Fix Autoload in CIFix RSpec "NameError: uninitialized constant X" in CI - a missing require, a Zeitwerk filename/class mismatch…
Jest "Your test suite must contain at least one test"Fix Jest "Your test suite must contain at least one test" - an empty file matched by testMatch, all tests ski…