Search code examples
phpunitphpstorm

Code coverage white-/blacklisting in PhpStorm


In my project I have a PHPUnit configuration with whitelisting for my code coverage and also some directories excluded. When executing PHPUnit with this configuration and output the code coverage, I only get the whitelisted files in the code coverage.

When I do the same within PhpStorm, it shows code coverage of all files instead of only the whitelisted files.

An example of my PHPUnit configuration:

<filter>
    <whitelist addUncoveredFilesFromWhitelist="true">
        <directory suffix=".php">../../../../Classes/*</directory>

        <exclude>
            <directory suffix=".php">../../../../Tests</directory>
        </exclude>
    </whitelist>
</filter>

See the screenshot: it shows that 0% of my files are tested in the Test folder, what is correct because I excluded that folder. But when excluded I don't want to see it as well.

Screenshot of how my coverage looks like in PhpStorm


Solution

  • AFAIK you cannot do anything about it -- it's how PhpStorm works right now. If clover coverage report mentions any file then parent folder of such file will have coverage info (0% in our case).

    https://youtrack.jetbrains.com/issue/WI-16792 -- watch this ticket (star/vote/comment) to get notified on any progress.