Reputation: 13781
I am trying to use the feature in PhpStorm for code coverage but it shows me this error saying
"No whitelist is configured, no code coverage will be generated."
I am running PHP 7.2 on my local Mac machine.
EDIT: I have already added phpunit settings for whitelisting and logggin
This is what my phpunit.xml file looks like:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./report" charset="UTF-8"
yui="true" highlight="true"
lowUpperBound="50" highLowerBound="80" />
</logging>
<php>
</php>
</phpunit>
I have also tried setting
processUncoveredFilesFromWhitelist
instead of
addUncoveredFilesFromWhitelist
But still the same error
Upvotes: 2
Views: 5208
Reputation: 11
Run below command. It worked for me. I am using PHP 7.1, Symfony(1.x)
and PHPUnit(5.7)
legacy version. So directory structure could be different according to the version.
symfony/lib> vendor/bin/phpunit --whitelist ../[valid dir name]/
--coverage-clover test.xml UnitTest ../[dir]/[file_name]
symfony/lib> vendor/bin/phpunit --whitelist ../plugins/
--coverage-clover test.xml UnitTest ../test/PluginAllTests.php
OR
symfony/lib> vendor/bin/phpunit --whitelist ../tests/
--coverage-clover test.xml UnitTest ../test/PluginAllTests.php
Upvotes: 1
Reputation: 2708
I ran into the same issue. This might help.
First, make sure you can run code coverage on the command line.
Then, look at what command Phpstorm is trying to run. It's given in the test output, second line:
Testing started at 16:44 ...
C:\...\php.exe -dxdebug.coverage_enable=1 C:/.../vendor/phpunit/phpunit/phpunit --coverage-clover C:\.\XXX.xml --no-configuration --filter "/(::XXX)( .*)?$/" App\XxxTest C:\XXX.php --teamcity
PHPUnit 7.3.3 by Sebastian Bergmann and contributors.
Error: No whitelist is configured, no code coverage will be generated.
I tried to run this on the command line myself, changing the paths.
What I noticed was "--no-configuration". This means it's not even reading my phpunit.xml file. To fix this, set Settings -> Languages & Frameworkds -> Php -> Test Frameworks -> "Default configuration file" to your phpunit.xml file.
You might have a different problem, but this might point you in the right direction.
Upvotes: 3
Reputation: 3557
You need to configure whitelisting, that's a phpunit setting, see https://phpunit.de/manual/6.5/en/code-coverage-analysis.html#code-coverage-analysis.whitelisting-files
Upvotes: 1