Nicolas Thery
Nicolas Thery

Reputation: 2448

Coverage PHPUnit 0% with Jetbrains PHPStorm

I'm using Codeigniter3 framework and a phpunit package ci-phpunit-test. I run php on zend server with zend debugger enabled.

My phpunit.xml file is there :

<phpunit
    bootstrap="./Bootstrap.php"
    colors="true"
    testsuite="CodeIgniter Application Test Suite">
    <testsuites>
        <testsuite name="CodeIgniter Application Test Suite">
            <directory suffix="test.php">./</directory>
            <exclude>./_ci_phpunit_test/</exclude>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist>
            <directory suffix=".php">../controllers</directory>
            <directory suffix=".php">../models</directory>
        </whitelist>
    </filter>
</phpunit>

I run the code coverage execution using the icon with a green play and dashes, this runs the following command :

"C:\Program Files (x86)\Zend\ZendServer\bin\php.exe" -dzend_debugger.enable_coverage=1 C:/Users/NICOLAS/AppData/Local/Temp/ide-phpunit.php --configuration C:\....\phpunit.xml

After running successfully all the tests, the Coverage PHPUnit side bar opens and only shows 0% coverage (I'm sure the tests go through a lot of code).

Here is what I get :

enter image description here

UPDATE : some more information... When I add this in the phpunit.xml file, it tells me Xdebug is not enabled:

<logging>
    <log type="coverage-html" target="build/coverage"/>
    <log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>

Therefore I tried enabling the xdebug debugger, the tests were veeeeeery slow to run and I got a HTML report in build/coverage folder. It's good but not integrated in PHPStorm environment.

So I went back to zend debugger and try the PHPStorm feature (removing the log section in phpunit.xml). Tests are quick to run but coverage stays at 0%...

Upvotes: 4

Views: 2449

Answers (1)

Senhorzim
Senhorzim

Reputation: 141

i had the same problem and this answer did the trick.

By changing the project root to the absolute path (/media/hdd/...) I was able to resolve the problem.

Upvotes: 1

Related Questions