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/