PHPunit的CodeCoverage无法生成 [英] CodeCoverage with PHPunit not generating

查看:178
本文介绍了PHPunit的CodeCoverage无法生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHPunit 3.7.1 PHP 5.3.14 Windows 7

PHPunit 3.7.1 PHP 5.3.14 Windows 7

使用cmd我将"cd"输入phpunit.xml所在的目录并运行

Using cmd I "cd" into the dir where phpunit.xml lives and run

phpunit -c phpunit.xml

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

but that dosen't generate any code coverage.

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

正常工作,但过滤器中的任何内容似乎均不起作用.

that works just fine, except nothing in the filter seem to work.

我在做什么错了?

推荐答案

我不知道phpunit是否支持在测试套件中定义过滤器和日志记录.独自定义所有内容应该可以:

I don't know if phpunit supports the definition of filter and logging inside a testsuite. Defining it all on it's own should work:

<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>

这篇关于PHPunit的CodeCoverage无法生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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