Search code examples
phpsymfony1doctrinecode-coveragephpunit

PHPUnit coverage now incomplete as class' opening brace is not covered


Hey everyone, I've been using PHPUnit to to do unit testing on a Symfony/Doctrine project I'm working on. It was working fine until yesterday when various classes dropped from 100% coverage to 98-99%. The reason for the change is because the opening left brace of these classes is no longer considered "covered" for some reason. Here's a screenshot of the issues:

http://imgur.com/RCDzm.png

I've tried everything but I can't figure out what causes some classes to have this issue while the others show "complete" coverage just fine. It's more of an annoyance than anything since the tests still run just fine but it'd be nice to know what is going on. I'm using PHP 5.3.2, PHPUnit v3.4.15, and Xdebug v2.1.0 in case that makes a difference.


Solution

  • Likely related to

    Sebastian marked it as wontfix in PHPUnit and Derick say it's not a bug.

    This is not a bug. Xdebug can only scans items (files, functions, methods) when they are loaded and code coverage is enabled. The class file is loaded before code coverage is enabled, and is therefore not picked up in the coverage report. The methods are scanned when they are run as well, so it works there.