0

I'm relearning PHPUnit, and I found the code-coverage command ./vendor/bin/phpunit --coverage-html coverage. When I do it, I get the No whitelist configured error, which I'm led to believe is also the error you get when your whitelist isn't setup properly, but I'm not sure what's wrong.

<phpunit colors="true" bootstrap="tests/bootstrap.php">
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">/src/*</directory>
            <!--<file>/path/to/file</file>-->
            <exclude>
                <!--<directory suffix=".php">/path/to/files</directory>-->
                <!--<file>/sr</file>-->
            </exclude>
        </whitelist>
    </filter>
    <testsuites>
        <testsuite name="Application Test Suite">
            <directory>tests</directory>
        </testsuite>
    </testsuites>
</phpunit>
4
  • why do you have the comments in the exclude section? Commented Jan 13, 2018 at 9:50
  • Sorry, I copied the format from a good, didn't need those parts and just commented them out while I tried to get it to work. The comments would be deleted before any commits. Is still valid XML so I didn't think it matters. Commented Jan 13, 2018 at 15:33
  • It matters I suppose, try to delete all the node out Commented Jan 13, 2018 at 16:58
  • Tried it out; there's no difference in behavior. Commented Jan 16, 2018 at 1:12

1 Answer 1

4
+50

Take in mind that paths are relative to phpunit.xml config file. Maybe

<directory suffix=".php">/src/*</directory>

should be

<directory suffix=".php">src/*</directory>

if phpunit.xml is on project root folder

Sign up to request clarification or add additional context in comments.

1 Comment

I didn't even notice I did that! Thanks for the catch and explanation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.