大家好,我一直在使用 PHPUnit 对我正在处理的 Symfony/Doctrine 项目进行单元测试。直到昨天,各种类别的覆盖率从 100% 下降到 98-99% 之前,它一直运行良好。更改的原因是因为某些原因不再将这些类的左左大括号视为“覆盖”。这是问题的屏幕截图:
我已经尝试了所有方法,但我无法弄清楚是什么原因导致某些类出现此问题,而其他类则显示“完整”覆盖范围很好。这比任何事情都更让人烦恼,因为测试仍然运行得很好,但很高兴知道发生了什么。我使用的是 PHP 5.3.2、PHPUnit v3.4.15 和 Xdebug v2.1.0,以防出现差异。
最佳答案
可能与
有关Sebastian 在 PHPUnit 中将它标记为 wontfix,Derick 说这不是一个错误。
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.
关于PHPUnit 覆盖现在不完整,因为类的左大括号没有被覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3294358/