4

When I run my test suite in PHPstorm, the code coverage comes back with 0% for everything (which I know is not true), and when I run PHPunit from the command line, the logged HTML output documents show that I actually DO have coverage and lists all the detailed information.

In PHPstorm, I have my PHP interpreter set to /usr/local/bin/php (PHP 5.6.7) and xdebug 2.3.2 (screenshot: https://dl.dropboxusercontent.com/u/379071/Screen%20Shot%202015-04-20%20at%206.57.39%20PM.png). In my PHPunit preferences, I have the 'path to script' set to my composer autoload.php file. In my runtime configuration, I have a PHPunit runtime set to run with a 'defined configuration file' (See below). When I run, all the tests run and pass (a failure shows a stack trace), but the code coverage is completely zero for everything.

Any help would be greatly appreciated. I'm sure I've just missed something.

Contents of my XML configuration file:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
         colors="true">
    <testsuites>
        <testsuite>
            <directory>tests</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist>
            <directory suffix=".php">src</directory>
        </whitelist>
    </filter>
    <logging>
        <log type="coverage-html" target="./log/codeCoverage" charset="UTF-8"
             yui="true" highlight="true"
             lowUpperBound="50" highLowerBound="80"/>
        <log type="testdox-html" target="./log/testdox.html"/>
    </logging>
</phpunit>
3
  • 1
    Most likely you are using symbolic links or your code is outside of the project and IDE is unable to match file names produced by xdebug to project files. Commented Apr 21, 2015 at 8:56
  • This was the issue. Wow, thanks for catching that! Commented Apr 21, 2015 at 12:26
  • 2
    So how did you actually fix this issue? I'm having the same problem. Commented Aug 4, 2015 at 18:30

2 Answers 2

5

I know this is an old thread but I just encountered this issue. In my case the project path contained a symlink to a different hd. By changing the project root to the absolute path (/media/hdd/...) I was able to resolve the problem.

Sign up to request clarification or add additional context in comments.

1 Comment

Turns out the same issue was with me - it was a symlink (same HDD, but a symlink nonetheless).
-2

Possible you just run tests without code coverage in phpstorm. You can invoke Run with coverage action. I have similar configurations and all works fine.

enter image description here

2 Comments

I made sure I was running with coverage - same issue. The 'coverage summary' side pane even opens up after the operation is complete.
My filter configuration. Possible add slash at the end <filter> <whitelist> <directory suffix=".php">src/</directory> </whitelist> </filter>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.