PHPUnit is not producing its clover coverage report
Asked Answered
E

2

7

Although phpunit supports the --coverage-clover [file] argument, it seems to be doing nothing.

I have Jenkins running on this server with the clover coverage plugin for php.

Here's my output:

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

Time: 745 ms, Memory: 16.75Mb

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

I'm looking to find out why the clover XML file is not being generated at all, with no error message. Even using the --debug flag produces nothing related to the clover report.

Version information:

> 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

This is my PHPUnit XML File:

<phpunit bootstrap="tests/bootstrap.php">
    <testsuites>
        <testsuite name="tests/suite">
            <directory>tests/suite</directory>
        </testsuite>
    </testsuites>
</‌​phpunit>
Engelhart answered 28/10, 2015 at 10:37 Comment(1)
How does your phpunit.xml look like?Misgiving
M
7

It seems like you didn't define a whitelist. Without any whitelist, no coverage data will be produced in PHPUnit 5. Try something like:

<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>
Misgiving answered 28/10, 2015 at 13:50 Comment(0)
S
0

There are some issues if several versions of phpunit are available on the system.

Here is a link that might help: https://github.com/sebastianbergmann/phpunit/issues/1253

Stephenson answered 4/4, 2018 at 19:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.