簡體   English   中英

升級到PHPUnit 5.5.4后,代碼覆蓋率報告不正確

[英]code coverage report not correct after upgrading to PHPUnit 5.5.4

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

單元測試仍然有效。 當我通過命令行運行它們時,我仍然看到所有測試都已成功執行,但這只是代碼覆蓋率報告的結果如此奇怪。

我正在運行5.5.4,這是最新的穩定版本,5.6是beta版本。 我向我添加了日志記錄,以查看它是否可以正常運行。 它在報告目錄中生成了一個HTML報告,該報告正確顯示了百分比。 這是我的phpunit.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" bootstrap="vendor/autoload.php">
    <testsuite name="Full Suite">
        <directory>tests/</directory>
    </testsuite>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">src</directory>
        </whitelist>
    </filter>
    <logging>
        <log type="coverage-html" target="report"/>
    </logging>
</phpunit>

因此它可能是beta版本,但是您至少可以看到我的xml文件,並且知道它適用於5.5.4。 祝好運!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM