PHPUnit. Error: No code coverage driver is available. (having xdebug installed)
I've faced this problem with a new installation of PHP 7.1 and this is what I've done to make it work
$ brew install php71-xdebug
$ php -i | grep xdebug
// to check if xdebug was installed
$ phpunit
After that it worked. Additionally this is how my phpunit.xml looks like I've needed to whitelist whole structure because it's shared component
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Tests">
<directory suffix=".php">./Tests/</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-clover" target="./build/logs/clover.xml"/>
</logging>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory>./</directory>
</whitelist>
</filter>
</phpunit>
This solution will work on MacOS only, if you want to make it work on Linux then you need to use applicable package manager like apt-get etc.
There are 2 php.ini
files in most Apache/PHP installations and definitely in WAMPServer
To amend the correct php.ini
used by PHP in Apache use the menus
wampmanager->PHP->php.ini
But for the php.ini
file used by the PHP CLI you have to manually edit
\wamp\bin\php\php{version}\php.ini
the result of a php -v
should look like this if XDEBUG is configured in the CLI
php -v
PHP 7.0.6 (cli) (built: Apr 27 2016 14:00:40) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
NOTE
The current WAMPServer 3 is 3.0.4
ADDON upgrades can be found on SourceForge
The latest ADDON PHP Version is PHP7.0.6 also available on SourceForge
See The WampServer Forum to keep up to date with the latest releases of PHP / MYSQL / Apache ADDONS for WAMPServer 3
Also :
You may find that you have to tweek the XDEBUG config parameters in the php.ini
to suit your specific needs
With the same problem on Debian:
Error: No code coverage driver is available
I fixed it with installing php-xdebug: sudo apt install php-xdebug