Dav*_*ess 4 php phpunit code-coverage xdebug
我知道100%的代码覆盖率只是一个目标,但是让一个包含右括号的行计为未覆盖是很烦人的,因为它遵循方法调用,其唯一目的是抛出异常.这是我的基础测试用例类中的一个简单示例,用于演示:
function checkForSkipAllTests() {
if (self::$_skipAllTests) {
self::markTestSkipped(); // [1] always throws an exception
} // [2] shown as executable but not covered
}
Run Code Online (Sandbox Code Playgroud)
由于[1]总是退出方法,因此行[2]实际上是不可达的.有没有办法通过注释方法本身来告诉Xdebug ?markTestSkipped()
你的pull请求已经合并,所以从php-code-coverage 1.1.2开始,这应该很快就会出现(使用PHPUnit 3.6.3或3.6.4),你可以写:
private static function checkForSkipAllTests() {
if (self::$_skipAllTests) {
self::markTestSkipped();
} // @codeCoverageIgnore
}
Run Code Online (Sandbox Code Playgroud)
同样在更远的未来,当xDebug将能够提供"条件"覆盖时,我想我会记得关于通过重构使整个问题消失的讨论,因为当函数中的最后一个语句时,右括号将被视为"覆盖"终止功能...但我可能错了