Michael Cordingley Michael Cordingley - 1 month ago 14
PHP Question

Why won't PHPUnit code coverage report functions that aren't called?

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.

Answer

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.