Hello:
Suppose the following section in phpunit.xml:
<phpunit colors="true" strict="true">
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/lalala/</directory>
</whitelist>
<blacklist>
<directory suffix=".php">./vendor</directory>
</blacklist>
</filter>
</phpunit>
Which did work fine until I moved all my code from /src/lalala/ to /src/. At that point, when I did run the tests to check everything, phpunit generated the following error:
Error: No whitelist configured, no code coverage will be generated
It would be much nicer to have another error such as "Whitelist directory doesn't exist" instead so it is easier to spot.
I'm posting this here instead of php-code-coverage because the error is generated over here: https://github.com/sebastianbergmann/phpunit/blob/master/src/TextUI/TestRunner.php#L341
If however, you need the issue to be created in the php-code-coverage repo let me know and I'll create it over there.
Greetings.
Check whether the directory listed in your <whitelist> tag exists. If it does not, correct your phpunit.xml so that it points to the correct folder.
Yeah, i'am using 5.5.0
and the same problem to me too :(
my phpunit.xml
<?xml version="1.0"?>
<!-- see http://www.phpunit.de/wiki/Documentation -->
<phpunit bootstrap="bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
forceCoversAnnotation="true">
<testsuites>
<testsuite name="unit">
<directory>tests/src/Alpha</directory>
</testsuite>
<testsuite name="functional">
<directory>tests/src/Functional</directory>
</testsuite>
<testsuite name="integration">
<directory>tests/src/Integration</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix="Test.php">/tests/src/</directory>
</whitelist>
</filter>
</phpunit>
then i execute
phpunit -v -c tests/phpunitxml --coverage-clover tests/reports/coverage.xml tests
then i receive
No whitelist configured, no code coverage will be generated
please, how can i do fix this?
Thanks!
you should whitelist files which contain logic (which you want to test, not your test files), your whitelist should be <directory suffix=".php">./src/</directory>
Thats ok, now I figured out .... but any one of my tests are not executed .... in the console it say to me: No tests executed!
Probably I made some mistake on my paths!
Anyway, thank you for the help!
I have the same problem (phpunit version 5.6)
My phpunit.xml configuration is:
<?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"
syntaxCheck="false"
>
<logging>
<log type="coverage-html"
target="./build/coverage/html"
charset="UTF-8"
highlight="false"
lowUpperBound="35"
highLowerBound="70"/>
<log type="coverage-clover"
target="./build/coverage/log/coverage.xml"/>
</logging>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
And I am getting ' No whitelist configured, no code coverage will be generated'.
Same problem for me. Bizarrely, same config works just fine on a Windows machine running PHP 7.0, but not on a Linux machine running PHP 5.5.
PHPUnit version is 5.7.16
Not sure if it's relevant but using PHPStorm IDE V 2016.3
Xdebug is installed in both environments
Tests run just fine without coverage (both environments)
Same here - my phpunit.xml has:
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app/</directory>
</whitelist>
</filter>
and I'm running PHP7.1 on ubuntu 16.04 in docker, phpunit version 6.0.10.
Getting Error: No whitelist configured, no code coverage will be generated. I've confirmed I'm reading in the right phpunit.xml file by changing the colors setting and that is taking effect.
Any help or ideas for what else to check would be appreciated, and if I can provide any more info let me know :)
Same issue as @katzien
I got this error with a misconfigured directory within whitelist. Maybe it's just a matter of inappropriate wording of the error message.
I fixed it! As @elmar-hinz said, it was a misconfigured path. The thing to remember is to make sure the path in whitelist is relative to the phpunit.xml file! D'oh. Sounds obvious now :D
@elmar-hinz Yeah, I guess would be nice if the message was something like "invalid whitelist path" or something, rather than "no whitelist configured" but oh well :)
@katzien And that is exactly what this issue is about: you MUST configure correctly your whitelist, however an indication about the correct folder would be nice(r).
I will try to edit the first post so that (one of) the "solutions" to this problem becomes more obvious.
Greetings.
Most helpful comment
I fixed it! As @elmar-hinz said, it was a misconfigured path. The thing to remember is to make sure the path in whitelist is relative to the phpunit.xml file! D'oh. Sounds obvious now :D