选项之间有什么区别

选项之间有什么区别

本文介绍了phpunit覆盖范围:"addUncoveredFilesFromWhitelist"和"processUncoveredFilesFromWhitelist"选项之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为特定目录的phpunit设置代码覆盖率.有人可以告诉我有什么区别吗?

I'm trying to set up code coverage for phpunit for a particular directory. Can someone tell me what is the difference between:

<filter>
    <whitelist>
        <directory suffix=".php">lib/</directory>
    </whitelist>
</filter>

<filter>
    <whitelist addUncoveredFilesFromWhitelist="true">
        <directory suffix=".php">lib/</directory>
    </whitelist>
</filter>

<filter>
    <whitelist processUncoveredFilesFromWhitelist="true">
        <directory suffix=".php">lib/</directory>
    </whitelist>
</filter>

当前,前两个选项可以工作(具有不同的覆盖范围号),但是第三个选项将失败,并出现类似于.

Currently the first 2 options will work (with different coverage numbers) but the third one will fail with errors similar to How to add uncovered files to PHPUnit code coverage report of the Yii application.

只是从phpunit开始,并且想了解这些白名单选项之间的区别.我已经阅读了官方文档,但是不确定我是否理解.

Just starting out with phpunit and would like to understand the differences between these whitelisting options. I read the official docs on this but I'm not sure I understand.

推荐答案

包揭示了事实:

  • 如果addUncoveredFilesFromWhitelist FALSE 然后代码覆盖率包含有关已加载和执行的文件的信息(仅包含包含代码的行);
    在这种情况下,processUncoveredFilesFromWhitelist的值将被忽略;
  • 如果addUncoveredFilesFromWhitelist TRUE ,那么白名单中尚未加载和执行的文件也将包括在代码覆盖范围内:
    • 如果processUncoveredFilesFromWhitelist FALSE 然后就不会以任何方式处理文件;它们的所有行都将在代码覆盖率中显示为未执行,即使是空行和仅包含注释的行也是如此;这是完成任务的快速而肮脏的方式;
    • 如果processUncoveredFilesFromWhitelist TRUE 然后包括文件,并使用XDebug的代码覆盖功能(与实际运行的文件相同)将仅包含代码的行放入报告中;这是缓慢的努力工作方式.
    • if addUncoveredFilesFromWhitelist is FALSE then the code coverage contains information about the files that were loaded and executed (only the lines that contain code are included);
      the value of processUncoveredFilesFromWhitelist is ignored in this case;
    • if addUncoveredFilesFromWhitelist is TRUE then the files from the white list that were not loaded and executed will be included in the code coverage too:
      • if processUncoveredFilesFromWhitelist is FALSE then the files are not processed in any way; all their lines will appear in the code coverage as not being executed, even the empty lines and the lines that contain only comments; this is the quick and dirty way to get the things done;
      • if processUncoveredFilesFromWhitelist is TRUE then the files are included and XDebug's code coverage functionality is used (the same as for the files that actually ran) to put into the report only the lines that contain code; this is the slow hard-working way.

      addUncoveredFilesFromWhitelist的默认值为TRUEprocessUncoveredFilesFromWhitelist的默认值为FALSE.这意味着白名单中未被覆盖(因为它们没有运行)的文件将使用快速方法包含在报告中,而覆盖率报告(精确(0%))是使用总行数来计算的比真实的更大.

      The default value for addUncoveredFilesFromWhitelist is TRUE and for processUncoveredFilesFromWhitelist is FALSE. This means the files from the whitelist that were not covered (because they didn't run) are included in the report using the quick way and their coverage report, while exact (0%), is computed using a total number of rows slightly bigger than the real one.

      但是,由于0仍然是0%,因此它认为这是在报告中包括未发现文件的最佳方法.

      However, since 0 out of anything is still 0%, it think this is the best way to include the uncovered files in the report.

      这篇关于phpunit覆盖范围:"addUncoveredFilesFromWhitelist"和"processUncoveredFilesFromWhitelist"选项之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 13:03