Phpunit: "No whitelist configured" error when directory *does* exist

Created on 1 Aug 2016  路  2Comments  路  Source: sebastianbergmann/phpunit

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 Welcome

ls ./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.

Most helpful comment

<directory suffix="*.php">./src/CustomerCenter/</directory> should be <directory suffix=".php">./src/CustomerCenter/</directory>

All 2 comments

<directory suffix="*.php">./src/CustomerCenter/</directory> should be <directory suffix=".php">./src/CustomerCenter/</directory>

Works for me. Thank you for the quick response.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

keradus picture keradus  路  4Comments

AnmSaiful picture AnmSaiful  路  4Comments

dkarlovi picture dkarlovi  路  3Comments

ezzatron picture ezzatron  路  3Comments

sebastianbergmann picture sebastianbergmann  路  4Comments