【发布时间】:2017-01-28 04:52:00
【问题描述】:
我将 PHP 5.6.24 与 PHPUnit 5.5.4 和 XDebug 2.4.1 一起使用,代码覆盖率达到 0.83%。 但是,在我使用 PHP 5.6.0 和 PHPUnit 4.7.7 和 XDebug 2.3.3 之前,代码覆盖率达到了 84% 以上。
我发现,从 PHP 5.5.x 开始,您需要有一个配置了白名单的 phpunit.xml。这对我来说是新的,所以我添加了以下文件:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./</directory>
<file></file>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="../results/report" lowUpperBound="35" highLowerBound="70"/>
</logging>
<testsuites>
<testsuite name="DTS">
<directory>./</directory>
</testsuite>
</testsuites>
</phpunit>
单元测试仍然有效。当我通过命令行运行它们时,我仍然看到所有测试都已成功执行,但只是代码覆盖率报告的结果如此奇怪。
【问题讨论】:
标签: php phpunit code-coverage