【问题标题】:PHPUnit is not producing its clover coverage reportPHPUnit 没有生成它的三叶草覆盖率报告
【发布时间】:2016-01-28 02:15:59
【问题描述】:

虽然 phpunit 支持 --coverage-clover [file] 参数,但它似乎什么也没做。

我在这台服务器上运行 Jenkins,并使用 php 的三叶草覆盖插件。

这是我的输出:

> phpunit --coverage-clover coverage.xml
................................                                  32 / 32 (100%)

Time: 745 ms, Memory: 16.75Mb

> ls -l
(coverage.xml is not present)

我正在寻找根本没有生成三叶草 XML 文件的原因,并且没有错误消息。即使使用--debug 标志也不会产生与三叶草报告相关的任何内容。

版本信息:

> phpunit --version
PHPUnit 5.0.5 by Sebastian Bergmann and contributors.

> php --version
PHP 5.6.14-1+deb.sury.org~trusty+1 (cli)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with the ionCube PHP Loader + Intrusion Protection from ioncube24.com v.5.0.4, Copyright (c) 2002-2015, by ionCube Ltd.
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans

这是我的 PHPUnit XML 文件:

<phpunit bootstrap="tests/bootstrap.php">
    <testsuites>
        <testsuite name="tests/suite">
            <directory>tests/suite</directory>
        </testsuite>
    </testsuites>
</‌​phpunit>

【问题讨论】:

  • 你的phpunit.xml看起来怎么样?

标签: php jenkins phpunit jenkins-plugins clover


【解决方案1】:

如果系统上有多个版本的phpunit,会有一些问题。

这是一个可能有帮助的链接: https://github.com/sebastianbergmann/phpunit/issues/1253

【讨论】:

    【解决方案2】:

    您似乎没有定义白名单。如果没有任何白名单,PHPUnit 5 中将不会生成任何覆盖率数据。尝试类似:

    <phpunit bootstrap="./test/bootstrap.php" colors="true">
        <testsuites>
            <testsuite name="Tests">
                <directory>./test</directory>
            </testsuite>
        </testsuites>
        <filter>
            <whitelist addUncoveredFilesFromWhitelist="true">
                <directory>./lib</directory>
            </whitelist>
        </filter>
    </phpunit>
    

    【讨论】:

    • 很好,但是即使添加了白名单,仍然没有生成三叶草文件:&lt;phpunit bootstrap="./tests/unit/_bootstrap.php" colors="true"&gt; &lt;testsuites&gt; &lt;testsuite name="BaseController"&gt; &lt;directory suffix="Test.php" phpVersion="7.0" phpVersionOperator="&gt;="&gt;./tests/unit/&lt;/directory&gt; &lt;/testsuite&gt; &lt;/testsuites&gt; &lt;filter&gt; &lt;whitelist addUncoveredFilesFromWhitelist="true"&gt; &lt;directory&gt;./tests/unit/&lt;/directory&gt; &lt;/whitelist&gt; &lt;/filter&gt; &lt;/phpunit&gt;
    猜你喜欢
    • 2011-07-15
    • 1970-01-01
    • 2011-03-09
    • 1970-01-01
    • 1970-01-01
    • 2014-03-21
    • 1970-01-01
    • 2019-01-29
    • 2012-05-04
    相关资源
    最近更新 更多