I use PHP 8.0.5 , PHPUnit 9.5.4, PHPStorm 2021.1.2. When, in my XML configuration file, I use this :
<coverage pathCoverage="true">
<report>
<clover outputFile="./coverage.xml"/>
</report>
</coverage>
(This is only the relevant portion of my file)
...and launch the command 'Run with coverage' from PHPStorm, it does not generate the coverage report.
I have deactivated XDebug. PHPStorm shows me :
Warning: XDEBUG_MODE=coverage or xdebug.mode=coverage has to be set
I do not know why it mentions XDebug as I want to use pcov as I set it in the "Run/Debug Configurations" popin. I try to put the report in another folder, try to generate HTML report instead... launch the command via the terminal ... None of this works. I did not find anything on Google about my issue.
EDIT
I tried with XDebug not loaded at all and this simplified configuration (created with the --generate-configuration
parameter) and added the previous code (without the path coverage).
<?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="TestBootstrap.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 suffix="Test.php">./src/BlocksTest.php</directory>
</testsuite>
</testsuites>
<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">../src</directory>
</include>
<report>
<clover outputFile="./coverage.xml"/>
</report>
</coverage>
</phpunit>
It still not works even if the library says :
Generating code coverage report in Clover XML format ...