2

Currently I am doing a whitebox test so the parent class and all interfaces are tested. This covers them all so I add the doc comment:

/**
 * @covers \Pat\Environment\PHP\Autoloader\Psr0<extended>
 */
public function testWhitebox() {}

phpUnit runs with success but the interface does not appear in the coverage.xml file. No matter if excluded or not.

<?xml version="1.0" encoding="UTF-8" ?>
<phpunit bootstrap="bootstrap.php">
    <filter>
        <blacklist>
            <file>*Interface.php</file>
        </blacklist>
    </filter>

    <logging>
        <log type="coverage-clover" target="./coverage.xml"/>
    </logging>
</phpunit>

The phpStorm IDE keeps counting it as file and therefor it is missing. Without that issue it would be 100% code coverage.

Code coverage in phpStorm

It is open for phpStorm and fixed for IntelliJ IDEA.

http://youtrack.jetbrains.com/issue/WI-14785

Any known workaround?

LeMike
  • 3,195
  • 5
  • 25
  • 35
  • 1
    How to cover something that doesn't even exist? *Coverage* is a *code coverage*. And you (by definition) don't have any implementations to test in interfaces. – zerkms May 05 '13 at 09:02
  • Well it counts as a file and that is missing in the XML. Then it is up to phpStorm or PHPUnit. – LeMike May 05 '13 at 09:44
  • I'm not sure I properly understand the question. Interfaces contain no executable code. How do you want to test them? What should be covered? – hakre May 05 '13 at 09:56
  • Also please add the commandline how you invoke PHPUnit to the question to add some more context. – hakre May 05 '13 at 09:57
  • I think you misinterpret the summary given next to the directory. It is perfectly correct to say 66% of the files are code-coveraged (it shows that there are some files that can not be covered at all for examples). As you can see, it says 100% of the lines. That value is important in your case. Not the file-percentage. – hakre May 05 '13 at 10:48

1 Answers1

2

How to fix that?

If this qualifies as a bug/flaw/new feature request in PHPStorm, you can report it as an issue in their issue tracker for PHPStorm (and other products).

Their personnel will then take care to fix that.


If you do not want to go that route, you can just ignore the file in your code-coverage statistics because you don't need to take it into account when calculating the percentage.

Community
  • 1
  • 1
hakre
  • 193,403
  • 52
  • 435
  • 836
  • Thanks. It is solved in IntelliJ but not solved for phpStorm. I saw the force discussion but this didn't work (see new information above). Still counting every file. – LeMike May 05 '13 at 10:41