I had PHPUnit configured to generate code coverage statistics using XDebug. Seeing that PCOV was faster, I disabled xdebug.so
and installed pcov.so
.
Now, whenever I run my unit tests, the generated coverage report has no numbers or names or anything:
Here's the script that calls phpunit:
#!/bin/bash
script_dir=$(dirname $0);
php $script_dir/phpunit.phar --coverage-html ../../public/coverage
Here is my phpunit.xml, which was unchanged in the process of moving from XDebug to PCOV:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="bootstrap.php"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">../../app/</directory>
</include>
<exclude>
<directory suffix=".php">../../app/config/</directory>
<directory suffix=".php">../../app/libs/</directory>
<directory suffix=".php">../../app/views/</directory>
</exclude>
</coverage>
</phpunit>
Here is the output:
PHPUnit 9.5.6 by Sebastian Bergmann and contributors.
Runtime: PHP 7.3.11 with PCOV 1.0.9
Configuration: /path/to/phpunit.xml
.............. 14 / 14 (100%)
Time: 00:00.751, Memory: 20.00 MB
OK (14 tests, 38 assertions)
Generating code coverage report in HTML format ... done [00:00.074]
PHP version: 7.3.11
PHPUnit version: 9.5.6
PCOV version: 1.09
Is there some additional configuration that needs to be done for PCOV or for PHPUnit for the coverage report to be useful?