php - PHPunit 的 CodeCoverage 未生成

标签 php phpunit code-coverage xdebug

PHPunit 3.7.1 PHP 5.3.14 Windows 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

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

我在这里做错了什么?

最佳答案

我不知道 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>

关于php - PHPunit 的 CodeCoverage 未生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13672946/

相关文章:

php - 从数据库读回时恢复换行符

visual-studio-2010 - VS2010 的代码覆盖 block

java - Java ASM 方法的封面

php - 在 PHPUnit 中自定义设置

java - Cobertura 显示 Tomcat 中检测 WAR 的覆盖率为 0%

php - APNs Provider API 批量请求

php - 从 php 调用的 python 脚本连接到数据库

php - Ubuntu 上下文错误默认时区上的 Symfony2

php - captureScreenshotOnFailure 不工作,损坏

php - 运行 phpunit 时未找到 fatal error 'File/Iterator/Autoload.php'