phpunit: Error: Incorrect whitelist config, no code coverage will be generated.

Q A
PHPUnit version 6.5.3
PHP version 7.1.4
Installation Method Composer

Recently (probably since updating to PHPUnit 6.5) PHPUnit started to print this error instead of code coverage. Is this a bug? I didn’t change anything regarding coverage recently. My whitelist configuration is very simple:

    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">src</directory>
        </whitelist>
    </filter>

How can I find out what is wrong here? It worked just fine some time before.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 20 (2 by maintainers)

Most upvoted comments

Phpunit should include specific error messages instead of saying incorrect whitelist configuration.

On Mar 1, 2018 10:45 AM, “Bouke Versteegh” notifications@github.com wrote:

I got this error when running a single testcase from PhpStorm, which disables the phpunit.xml by default, so there is no whitelist, and thus no coverage. It works when running the whole project.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sebastianbergmann/phpunit/issues/2915#issuecomment-369633588, or mute the thread https://github.com/notifications/unsubscribe-auth/Ac5oMy6AWUf3VdUj7ttyDXWx85GgJ6pnks5taBeXgaJpZM4Q9QbM .

@locojuhi,

🔧 Check your filter section on phpunit.xml, every directory value must be exist on you work directory.

For example

    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./src</directory>
        </whitelist>
    </filter>

⚠️ If ./src don’t exist, you get Incorrect whitelist config, no code coverage will be generated.

Same issue, solved.

Not working :

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false">
    <testsuites>
        <testsuite name="Package Test Suite">
            <directory suffix=".php">./tests/</directory>
        </testsuite>
    </testsuites>
</phpunit>

Working:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
>
    <testsuites>
        <testsuite name="Package Test Suite">
            <directory suffix=".php">./tests/</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">src</directory>
        </whitelist>
    </filter>
</phpunit>

@enumag Is that literally your entire PHPUnit configuration? The reason I ask is that we also get this message since 6.5, and it comes from having more than one <whitelist> section. I guess there could be multiple unrelated reasons that cause that error starting in 6.5, but it would be good to rule out that it’s the same issue.

A minimal example of our issue is as follows:

<phpunit>
    <filter>
        <whitelist>
            <directory>A</directory>
        </whitelist>
        <whitelist>
            <directory>B</directory>
        </whitelist>
    </filter>
</phpunit>

So long as directories A and B do actually exist, this produces no error in <6.5, but produces “Incorrect whitelist config, no code coverage will be generated” in >=6.5 (not sure what the recommended way is now to have processUncoveredFilesFromWhitelist set differently for two dirs).

I used https://github.com/ankurk91/phpunit-travis-ci-coverage-example as a reference.

On Mon, Mar 12, 2018, 7:16 PM COTE notifications@github.com wrote:

Hi

Is there somewhere a simple sample of a correct xml config file for coverage ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sebastianbergmann/phpunit/issues/2915#issuecomment-372493885, or mute the thread https://github.com/notifications/unsubscribe-auth/Ac5oMx3gSm03LI1ec2SE13PKybUDYODdks5tdwHWgaJpZM4Q9QbM .

In case anyone else is looking, this error can also appear if you include

<log type="coverage-html" target="../webroot/reports" />

In your phpunit.xml, when there are no filter or whitelist elements present, so zero nodes is another trigger.

@Nenglish7 i tried that, but still not working for me… anyone could solve this issue?