PHPUnit未生成其三叶草覆盖率报告

Sea*_*ean 5 php phpunit clover jenkins jenkins-plugins

尽管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)
Run Code Online (Sandbox Code Playgroud)

我正在寻找找出为什么根本没有生成三叶草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
Run Code Online (Sandbox Code Playgroud)

这是我的PHPUnit XML文件:

<phpunit bootstrap="tests/bootstrap.php">
    <testsuites>
        <testsuite name="tests/suite">
            <directory>tests/suite</directory>
        </testsuite>
    </testsuites>
</??phpunit>
Run Code Online (Sandbox Code Playgroud)

kel*_*nik 5

似乎您没有定义白名单。没有任何白名单,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>
Run Code Online (Sandbox Code Playgroud)