PHPstorm PHPunit 代码共同覆盖

2022-01-25 00:00:00 code-coverage php phpunit phpstorm

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>

解决方案

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.

相关文章