【问题标题】:How to turn off code coverage for phpunit 5.4+如何关闭 phpunit 5.4+ 的代码覆盖率
【发布时间】:2016-10-22 06:39:07
【问题描述】:

在旧版本的 phpunit 中,您可以使用以下标志关闭代码覆盖率报告:--no-coverage。这使我们的套件在 CI 环境等上运行得更快。在当前的稳定版本 (5.4) 中,我在 the docs 中看不到这个选项。目前关闭代码覆盖率的方法是什么?

【问题讨论】:

    标签: php phpunit


    【解决方案1】:

    文档中可能缺少--no-coverage 选项,但它对我有用。

    它还在 PHPUnit 的代码中,请参阅 Command.php:66Command.php:523


    我创建了一个包含 1 个类和 1 个测试的小型测试项目来试用它。我在 phpunit.xml<logging> 部分启用了代码覆盖率输出 (HTML)。

    不带选项运行 phpunit:

    $ phpunit
    PHPUnit 5.4.6 by Sebastian Bergmann and contributors.
    
    [removed irrelevant output]
    
    OK (1 test, 1 assertion)
    
    Generating code coverage report in HTML format ... done
    

    正在生成并输出代码覆盖率。

    使用以下选项运行 phpunit:

    $ phpunit --no-coverage
    PHPUnit 5.4.6 by Sebastian Bergmann and contributors.
    
    [removed irrelevant output]
    
    OK (1 test, 1 assertion)
    

    没有代码覆盖生成。 (命令也跑得更快了。)

    【讨论】:

      猜你喜欢
      • 2012-05-04
      • 2012-08-04
      • 2018-05-29
      • 2012-01-18
      • 1970-01-01
      • 1970-01-01
      • 2012-01-14
      • 2011-05-27
      • 2017-02-22
      相关资源
      最近更新 更多