After upgrading from phpunit 4 to 5 I have issues generating coverage reports,
since phpunit 4.x has issues with generating Mocks with scalar type hints I am forced to upgrade.
Using the exact same configuration with phpunit "~4.0" (4.8.27) instead of "~5.0" results
in working code coverage - however I will have to skip lots of tests ....
Given following configuration in project root directory:
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.4/phpunit.xsd"
colors="true"
backupGlobals="false"
bootstrap="vendor/autoload.php"
>
<filter>
<whitelist
addUncoveredFilesFromWhitelist="true"
processUncoveredFilesFromWhitelist="true">
<directory suffix="*.php">./src/CustomerCenter/</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./tests/coverage/html/"/>
<log type="coverage-clover" target="./tests/coverage/coverage.xml"/>
</logging>
<testsuites>
<testsuite name="Unit Tests">
<directory suffix="Test.php">./tests/Test/CustomerCenter/</directory>
</testsuite>
</testsuites>
</phpunit>
Running phpunit via terminal and IDE from the project root results in the error
message despite the directories being there:
ls ./src/CustomerCenter/
Application Common EmbedCode IO Registration Welcomels ./tests/coverage/
html
Using:
PHP 7.0.9 (cli) (built: Jul 21 2016 08:19:58) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.9, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
compiled on OS X 10.11.6 via macports, xdebug support on cli is enabled:
php70 -i | grep "xdebug support"
xdebug support => enabled
Console output:
php70 bin/phpunit -c phpunit.xml
PHPUnit 5.4.8 by Sebastian Bergmann and contributors.
Error: No whitelist configured, no code coverage will be generated
..............................................SSS 49 / 49 (100%)
Time: 298 ms, Memory: 12.00MB
OK, but incomplete, skipped, or risky tests!
Tests: 49, Assertions: 70, Skipped: 3.
phpunit is loaded via composer autoload.
<directory suffix="*.php">./src/CustomerCenter/</directory> should be <directory suffix=".php">./src/CustomerCenter/</directory>
Works for me. Thank you for the quick response.
Most helpful comment
<directory suffix="*.php">./src/CustomerCenter/</directory>should be<directory suffix=".php">./src/CustomerCenter/</directory>