{"record":{"id":"8ad95759887d11f7","repo":"sebastianbergmann/phpunit","slug":"configured-code-coverage-driver-class-s-does-no","errorCode":null,"errorMessage":"Configured code coverage driver class \"%s\" does not exist","messagePattern":"Configured code coverage driver class \"(.+?)\" does not exist","errorType":"exception","errorClass":"CodeCoverageDriverException","httpStatus":null,"severity":"error","filePath":"src/Runner/CodeCoverage.php","lineNumber":608,"sourceCode":"            $this->collectsPathCoverage   = $pathCoverage;\n        } catch (CodeCoverageException $e) {\n            $message = $e->getMessage();\n\n            if ($message === '') {\n                $message = 'Code coverage cannot be initialized';\n            }\n\n            EventFacade::emitter()->testRunnerTriggeredPhpunitWarning($message);\n        }\n    }\n\n    /**\n     * @phpstan-ignore return.internalClass\n     */\n    private function instantiateDriver(string $driverClass, Filter $filter, Granularity $granularity): Driver\n    {\n        if (!class_exists($driverClass)) {\n            throw new CodeCoverageDriverException(\n                sprintf(\n                    'Configured code coverage driver class \"%s\" does not exist',\n                    $driverClass,\n                ),\n            );\n        }\n\n        /** @phpstan-ignore classConstant.internalClass */\n        if (!is_subclass_of($driverClass, Driver::class)) {\n            throw new CodeCoverageDriverException(\n                sprintf(\n                    'Configured code coverage driver class \"%s\" does not extend %s',\n                    $driverClass,\n                    /** @phpstan-ignore classConstant.internalClass */\n                    Driver::class,\n                ),\n            );\n        }","sourceCodeStart":590,"sourceCodeEnd":626,"githubUrl":"https://github.com/sebastianbergmann/phpunit/blob/f123cdb2a2d49f15025794166cfed8bda8627dd2/src/Runner/CodeCoverage.php#L590-L626","documentation":"phpunit.xml configures a custom code coverage driver via the driver attribute of the <coverage> element (parsed by the XML configuration loader). When coverage is activated, PHPUnit tries to load that class and class_exists() failed — the FQCN is misspelled, its package is not installed or autoloadable, or an extension it depends on is missing. The CodeCoverageDriverException aborts coverage initialization.","triggerScenarios":"<coverage driver=\"App\\Coverage\\MyDriver\"> where that class does not exist — typo, wrong namespace, the composer package providing it not required, or a phar/extension not loaded in the current environment.","commonSituations":"Custom drivers (e.g., wrapping a vendor-specific collector) referenced before the package was added; refactors renaming driver classes; case or leading-backslash mistakes in the FQCN; CI missing a PHP extension the driver class file depends on.","solutions":["Check the exact FQCN in the driver attribute against the class's namespace and spelling.","Ensure the package providing the driver is installed and autoloaded (composer install, composer dump-autoload).","Verify quickly in the same environment: php -r 'var_dump(class_exists(\"App\\\\Coverage\\\\MyDriver\"));'.","If you do not need a custom driver, remove the driver attribute so PHPUnit auto-selects Xdebug/PCOV."],"exampleFix":"<!-- before -->\n<coverage driver=\"App\\Covrage\\MyDriver\"/>\n\n<!-- after -->\n<coverage driver=\"App\\Coverage\\MyDriver\"/>","handlingStrategy":"validation","validationCode":"// Preflight the driver attribute before running with coverage\n$class = 'App\\\\Coverage\\\\MyDriver'; // read from phpunit.xml in practice\nif (!class_exists($class)) {\n    fwrite(STDERR, \"Coverage driver {$class} does not exist; check the <coverage driver=...> setting\\n\");\n    exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a tiny preflight script (or CI step) that class_exists()s the configured driver class.","Add the driver package to the same composer constraint set as phpunit/phpunit.","Run phpunit --migrate-configuration after upgrades and review generated attributes."],"tags":["phpunit","php","code-coverage","configuration"],"backgroundTag":"coverage-driver-misconfigured","analyzedSha":"f123cdb2a2d49f15025794166cfed8bda8627dd2","analyzedAt":"2026-08-23T01:20:58.058Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}