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:
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:
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
请先登录再写评论。
Hi Dario,
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).
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:
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:
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:
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
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:
Andriy,
Thank you for the first-class assistance!:)
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!
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