PHPUnit "No code coverage driver available" in CI
PHPUnit was asked to produce coverage but the PHP on the runner has no coverage driver. PHPUnit needs Xdebug or PCOV loaded to record which lines run, and exits with an error when neither is present.
What this error means
A coverage run fails with "Error: No code coverage driver is available" or a warning that coverage was skipped. Tests may run, but the coverage report step errors out.
PHPUnit
Error: No code coverage driver is available.
To enable code coverage, install and enable Xdebug (in coverage mode) or PCOV.Common causes
Neither Xdebug nor PCOV is enabled
The runner PHP has no coverage extension loaded, so PHPUnit cannot collect line coverage.
Xdebug is installed but not in coverage mode
Xdebug 3 needs xdebug.mode=coverage; without it the extension is present but provides no coverage driver.
How to fix it
Enable a coverage driver on the runner
- Configure the PHP setup to include PCOV or Xdebug in coverage mode.
- For Xdebug 3, set
xdebug.mode=coverage. - Re-run the coverage command.
.github/workflows/ci.yml
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: pcovOr set Xdebug coverage mode
If you use Xdebug, switch it to coverage mode for the run.
Terminal
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-textHow to prevent it
- Provision a coverage driver (PCOV or Xdebug) when CI collects coverage.
- Set
xdebug.mode=coveragewhen relying on Xdebug. - Skip coverage flags on jobs that do not need a report to avoid the error.
Related guides
PHPUnit "Could not read phpunit.xml" configuration in CIFix PHPUnit "Could not read phpunit.xml" / "Cannot open file" in CI - PHPUnit cannot find or parse the config…
PHPUnit "Incomplete" tests reported in CIFix PHPUnit "There was 1 incomplete test" in CI - markTestIncomplete left tests unfinished, which can mask ga…
pytest warning turned into an error by filterwarnings in CIFix pytest failures where a warning becomes an error in CI - with filterwarnings = error a DeprecationWarning…