PHPUnit Code Coverage - Issue?

Hi Community

Since today I'm using the new version of PHPStorm with the integrated Code Coverage (thanks guys for one more great future in this great tool :-))

So far everything seems working. I have only one point on which I'm confused. I can not figure out, why the indication of the coverage is showing me this part
not covered. But let's start from zero:

Bildschirmfoto 2012-03-14 um 01.22.12.png

The green indication on line 76 indicates that this part of the code is covered. When I now go to the function, the hole function is marked as not covered:

Bildschirmfoto 2012-03-14 um 01.23.49.png
So my question now is, does I just don't understand how the Coverage of PHPUnit works, or is this a issue?

Thanks for your help

Regards, Dario

Comment actions Permalink

Hi Dario,

So my question now is, does I just don't understand how the Coverage of PHPUnit works...

Quite likely that is the case (IMHO, of course). It all depends on how you test -- show us test code (whole method, including PHPDoc block comment).

Comment actions Permalink

Hi Andry

Sorry for the late response.

As I understand it, every part of the code should be marked green which is passed through.

I have a couple of tests:

Bildschirmfoto 2012-03-14 um 21.16.47.png
One of this should run through the mentioned method which is marked as "Non Covered".

To show you what I mean I have implemented an echo into the function:

Bildschirmfoto 2012-03-14 um 21.18.06.png

As you can see on the left it's marked red, also non covered.

Now I let the script run with the coverage method and here the result:

Bildschirmfoto 2012-03-14 um 21.19.11.png

As you can see, the echo output is there "Hi Andry, I'm here".
But the hole function is still marked as not covered.

Because of that I have no idea what I'm doing wrong? :)

Thanks a lot for your help!

Regards, Dario

Comment actions Permalink

Pay attention to the @covers PHPDoc style tag -- it will mark as covered only function(s) mentioned in that tag, so any additionally called functions during tested function execution will not be counted in coverage report. If you do not want such behavior then get rid of those tags and observe the difference.

Useful link:

Comment actions Permalink


Thank you for the first-class assistance!:)

Comment actions Permalink

Hello Dario,

Please follow Andriy's advice. Also please note that PhpStorm just shows your report generated by PHPUnit. All issues about covered/uncovered code are related to PHPUnit or its configuration.

Thank you for feedback!

Comment actions Permalink

Andry thank you very much for your help! Not it works correctly :)

I just love this community... nowhere else you get that fast an answer on  problem :)

Keep on this way!

Regards, Dario


Please sign in to leave a comment.