I am using Laravel 8 and to test my app, I am running
php artisan test --coverage-html reports
The tests are running successfully. The problem is that there is no coverage reports generated. I have gone through answers here on SO and solution is said to add the below to my phpunit.xml
<logging>
<log type="coverage-html" target="tests/coverage" showUncoveredFiles="true"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
That doesn't work. I also tried
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
</include>
<report>
<html outputDirectory="tests/reports/coverage"/>
</report>
</coverage>
Still nothing; Below is my phpunit.xml
file
<?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="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
<directory suffix="Test.php">./packages/okotieno</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="tests/coverage" showUncoveredFiles="true"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="MAIL_DRIVER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<env name="DB_DATABASE" value="testing_db"/>
</php>
</phpunit>
I also ran php artisan test --help
to see the valid flags, --coverage-html
is not in the list but it runs. How can I fix this?
xdebug
or not to do so. I also had problems a few years back when trying to generate coverage reports, so I ended up usingxDebug
coverage (with PHPStorm). – Photodisintegration