Skip to content
Latchkey

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

  1. Configure the PHP setup to include PCOV or Xdebug in coverage mode.
  2. For Xdebug 3, set xdebug.mode=coverage.
  3. Re-run the coverage command.
.github/workflows/ci.yml
- uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    coverage: pcov

Or set Xdebug coverage mode

If you use Xdebug, switch it to coverage mode for the run.

Terminal
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text

How to prevent it

  • Provision a coverage driver (PCOV or Xdebug) when CI collects coverage.
  • Set xdebug.mode=coverage when relying on Xdebug.
  • Skip coverage flags on jobs that do not need a report to avoid the error.

Related guides

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