I tried to migrate from PHP 7 to PHP 8. I`ve updated all dependencies and then convert the PHPUnit configuration with the following command:
./vendor/bin/phpunit -c phpunit.xml --migrate-configuration
The problem is the coverage report is not generated anymore?! while all test are ok.
Here is the result phpunit.xml fild:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="./vendor/autoload.php"
stopOnWarning="false"
verbose="false"
backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
colors="true">
<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
<directory suffix=".php">./http-process</directory>
</include>
<report>
<clover outputFile=".build/clover.xml" />
<html outputDirectory=".build/coverage" />
</report>
</coverage>
<php>
<var name="DB_DSN" value="sqlite::memory:" />
<var name="DB_USER" value="root" />
<var name="DB_PASSWD" value="" />
<var name="DB_DBNAME" value="pluf_test" />
<var name="DB_SCHEMA" value="sqlite" />
</php>
<testsuites>
<testsuite name="http process">
<directory>./tests/Process/Http/</directory>
</testsuite>
</testsuites>
<!-- Code coverage -->
<logging />
</phpunit>
All test runs ok, but no coverage report!!.
2
Answers
I googled to find the issue. finally, I`ve found a solution. In my case, xdebug configuration was the problem. There is a setting for XDebug which enables or disables features of xdebug. As you know coverage is XDebug feature. So I just enable the feature as follow:
It also supports:
for more information see Code Coverage:
Maybe the last
<logging />
element overridescoverage/report
?