如何通过Netbeans/PHPStorm/PHPUnit集成从文件覆盖范围中排除文件/代码块 [英] How to exclude files / code blocks from code coverage with Netbeans / PHPStorm / PHPUnit integration

查看:77
本文介绍了如何通过Netbeans/PHPStorm/PHPUnit集成从文件覆盖范围中排除文件/代码块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要求:

  • 带有PHPUnit(6.9)的Netbeans
  • 编辑:例如,同样适用于PHPStorm
  • Netbeans with PHPUnit(6.9)
  • Same applies, for example, to PHPStorm

方法:

  • 从代码覆盖范围中排除行.
  • 从代码覆盖范围中排除代码块(行).

推荐答案

如果您试图实现100%的代码覆盖率,但是有一条或多条无法测试的行,则可以在它们周围加上特殊的注释.它们将在代码覆盖率报告中被忽略.

If you are trying to achieve 100% code coverage but have one or more lines that you cannot test, you can surround them with special annotations. They will be ignored in the code coverage report.

if (($result = file_get_contenst($url)) === false) {
    // @codeCoverageIgnoreStart
    $this->handleError($url);
    // @codeCoverageIgnoreEnd
}

我发现Xdebug通常认为右括号是可执行的. :(如果发生这种情况,请将结束标记移到其下方.

I have found that Xdebug often considers the closing brace to be executable. :( If that happens, move the end tag below it.

这篇关于如何通过Netbeans/PHPStorm/PHPUnit集成从文件覆盖范围中排除文件/代码块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆