skip to Main Content

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


  1. Chosen as BEST ANSWER

    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:

    xdebug.mode=debug,coverage
    

    It also supports:

    • off: Nothing is enabled.
    • develop: Enables Development Aids including the overloaded var_dump().
    • coverage: Enables Code Coverage Analysis
    • debug: Enables Step Debugging.
    • gcstats: Enables Garbage Collection Statistics
    • profile: Enables Profiling
    • trace: Enables the Function Trace feature

    for more information see Code Coverage:


  2. Maybe the last <logging /> element overrides coverage/report?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search