CodeCoverage with PHPunit not generating

巧了我就是萌 提交于 2019-12-24 04:57:15

问题


PHPunit 3.7.1 PHP 5.3.14 Windows 7

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

when I run

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

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

What am I doing wrong here?


回答1:


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>


来源:https://stackoverflow.com/questions/13672946/codecoverage-with-phpunit-not-generating

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!