PHPUnit代码覆盖率不适用于配置

时间:2010-08-27 18:07:24

标签: php unit-testing code-coverage phpunit

我的PHPUnit设置和覆盖率报告工作正常,没有白名单过滤器。然而,一旦我添加一个,报告似乎只是部分生成,好像PHPUnit意外退出。我没有收到任何错误或警告。

我的configuratoon看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./bootstrap.php"
         colors="true">
    <testsuites>
        <testsuite name="...">
            <testsuite name="...">
                <directory>./path/to/suite</directory>
            </testsuite>
            <testsuite name="...">
                <directory>./path/to/suite2</directory>
            </testsuite>
            <testsuite name="...">
                <directory>./path/to/suite3</directory>
            </testsuite>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist>
            <directory suffix=".php">../path/to/files</directory>
        </whitelist>
    </filter>

    <logging>
        <log type="coverage-html" target="log/" charset="UTF-8" yui="true" />
    </logging>
</phpunit>

关于可能出现什么问题的任何想法?

2 个答案:

答案 0 :(得分:1)

原来有一些脚本在我白名单的文件中暂停程序代码。

答案 1 :(得分:1)

很抱歉挖了一个旧的,但是我搜索了phpunit代码覆盖率不起作用而且这个出现了。

我让代码覆盖只是运行它的过程(认为xdebug用于它)并且暂时没问题。

然后,当我创建一个新测试时,它突然停止工作,运行的代码标记为未覆盖。

我用phpunit创建的测试类:phpunit-skelgen --test

那个创建覆盖注释,如:@covers MyClass :: someMethod

删除它们解决了它,xdebug现在再次使用,突然有100%的覆盖率。

关于报道的一点评论;只需调用一次方法就可以在报告中覆盖它,但大部分都不能被视为涵盖范围。使用空值和无效值调用它会覆盖它。

相关问题