【问题标题】:CodeCoverage with PHPunit not generating未生成 PHPunit 的 CodeCoverage
【发布时间】:2012-11-20 07:27:12
【问题描述】:

PHPunit 3.7.1 PHP 5.3.14 视窗 7

使用 cmd 我“cd”到 phpunit.xml 所在的目录并运行

phpunit -c phpunit.xml

但这不会产生任何代码覆盖率。

phpunit.xml:

<phpunit
bootstrap="./bootstrap.php"
verbose="true"
>
    <testsuites>
        <testsuite name="Test Suite">
            <directory suffix=".php">./Base/src/</directory>
            <filter>
                <whitelist addUncoveredFilesFromWhitelist="true">
                    <directory suffix=".php">../src</directory>
                    <exclude>
                        <directory suffix=".php">../../vendor</directory>
                    </exclude>
                </whitelist>
            </filter>
            <logging>
                <log type="coverage-html" target="./CodeCoverage/"/>
            </logging>
        </testsuite>
    </testsuites>
</phpunit>

当我跑步时

phpunit -c phpunit.xml --coverage-html CodeCoverage

效果很好,但过滤器中似乎没有任何效果。

我在这里做错了什么?

【问题讨论】:

    标签: php phpunit code-coverage xdebug


    【解决方案1】:

    我不知道 phpunit 是否支持在测试套件中定义过滤器和日志记录。自己定义它应该可以工作:

    <phpunit
    bootstrap="./bootstrap.php"
    verbose="true">
        <testsuites>
            <testsuite name="Test Suite">
                <directory suffix=".php">./Base/src/</directory>
            </testsuite>
        </testsuites>
        <filter>
            <whitelist addUncoveredFilesFromWhitelist="true">
                <directory suffix=".php">../src</directory>
                <exclude>
                    <directory suffix=".php">../../vendor</directory>
                </exclude>
            </whitelist>
        </filter>
        <logging>
            <log type="coverage-html" target="./CodeCoverage/"/>
        </logging>
    </phpunit>
    

    【讨论】:

      猜你喜欢
      • 2014-08-22
      • 1970-01-01
      • 1970-01-01
      • 2022-06-17
      • 2019-12-02
      • 2014-08-17
      • 2014-03-21
      • 2013-04-12
      • 1970-01-01
      相关资源
      最近更新 更多