2

I'm trying to get code coverage on one of my projects, but functions and classes that aren't called don't factor into the coverage calculations. It's hard to see what isn't covered yet (lots) when large chunks of code are ignored.

In the image below, I would expect the bodies of the first three functions to be highlighted red. Lines that aren't executed in functions that do get executed show up red, at least.

Uncovered Lines

For what it's worth, I'm running Debian Testing with PHP 7.0.12-1 and XDebug 2.4.1-1 as installed by apt and using PHPUnit 4.8.27 as installed by Composer.

Michael Cordingley
  • 1,485
  • 1
  • 11
  • 23
  • Interesting, removing `processUncoveredFilesFromWhitelist="true"` from my phpunit.xml appears to have made it better, though not all of the way. I'm getting most functions showing up red and counting against my coverage now. But... not all are doing that. There are still some that aren't marked at all. I'm not sure what the pattern is, but I'm at least on to something now. – Michael Cordingley Oct 27 '16 at 18:39
  • From [this question](https://stackoverflow.com/questions/29041254/phpunit-coverage-what-is-the-difference-between-adduncoveredfilesfromwhitelist#29042391), it looks as if having the option set should lead to a MORE accurate report, since it calculates it rather than using a heuristic. – Michael Cordingley Oct 27 '16 at 18:48
  • I just asked something related, or similar. Is this problem still based on the xdebug error? https://stackoverflow.com/questions/46133501/phpunit-symfony-why-coverage-shows-white-instead-of-red-and-gives-100-on-unt – Xavi Montero Sep 10 '17 at 14:00

2 Answers2

0

Code coverage reports should include all code in their calculations, not just stuff that is coloured. Are you sure the non-highlighted code is being excluded? Non-highlighted code is just code that has no tests, red highlights are for bits of code inside methods that have tested code but haven't been tested (like a conditional statement where you only tested one side of the condition)

  • The functions that aren't highlighted aren't being counted. For a class with no highlighted functions, this leads to a 0/0 count and the class being marked as 100% covered. – Michael Cordingley Oct 24 '16 at 14:57
0

This appears to be an ongoing bug with XDebug and PHP 7.0, as covered in this issue: https://github.com/sebastianbergmann/php-code-coverage/issues/411 So, it should be working as I expect and there's nothing incorrect about my setup. Guess I'll just have to wait until the underlying cause (in XDebug) is found and fixed. Until then, the thread notes that turning on process isolation is a work-around.

Michael Cordingley
  • 1,485
  • 1
  • 11
  • 23