Running PHPUnit from Eclipse result in 0 % for code coverage

14 Views Asked by At

I'm a beginner with Eclipse and PHPUnit. I think I configured my PHP project correctly to run PHPUnit with code coverage. My problem is : when I run PHPUnit from Eclipse, the tests are executed normally, the html report is generated, but all coverage lines and functions have the value "0%" :

coverage lines and functions have the value "0%"

If I run PHPUnit in the terminal with the command vendor/bin/phpunit (it uses the same phpunit.xml than in Eclipse) the html content is correct :

coverage lines and functions are documented

I don't understand why the coverage is empty if I start PHPUnit from Eclipse. Do you have an idea for me ?

Thanks for your help !

Softwares versions I use :

  • Eclipse 2023-12 (4.30.0)
  • PHP 8.1.2
  • PHPUnit 9.6 (installed with Composer)

My phpunit.xml :

<?xml version="1.0" encoding="UTF-8"?>
<phpunit
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
    bootstrap="tests/bootstrap.php">
    <testsuites>
        <testsuite name="unit">
            <directory>tests/unit</directory>
         </testsuite>
    </testsuites>
    <coverage includeUncoveredFiles="true"
          processUncoveredFiles="false"
          pathCoverage="false"
          ignoreDeprecatedCodeUnits="true"
          disableCodeCoverageIgnore="true">
        <include>
            <directory suffix=".php">src</directory>
        </include>
        <report>
            <html outputDirectory="html-coverage" lowUpperBound="50" highLowerBound="90"></html>
        </report>
    </coverage>
</phpunit>

The Eclipse profile I use to start PHPUnit :

enter image description here

In Eclipse, I started the debugger to get the phpunit command line parameters and start the program with the same parameters in the terminal :

path/of/phpunit --include-path /tmp/phpunit_printer --printer PHPUnitLogger --configuration /path/of/my/project/phpunit.xml /path/of/my/project/tests/unit

The code coverage is documented, as when I run phpunit without parameters.

0

There are 0 best solutions below