Include modules in code coverage
At the end, your application’s coverage report includes Modules/Blog/app. Prerequisites: phpunit.xml in the application root, modules_statuses.json, and a coverage driver (Xdebug or PCOV).
-
Update
phpunit.xml.Terminal window php artisan module:update-phpunit-coverageThe command reads the statuses file configured in
modules.activators.file.statuses-file(defaultmodules_statuses.json). It adds each enabled module’sappfolder to<source><include>and removes disabled or deleted modules.phpunit.xml <source><include><directory>app</directory><directory suffix=".php">./Modules/Blog/app/</directory></include></source>See
module:update-phpunit-coveragefor supported<source>XML layouts and exit codes. -
Run the tests with coverage.
Terminal window php artisan test --coverageWith Xdebug, enable coverage mode for the run:
Terminal window XDEBUG_MODE=coverage php artisan test --coverage
Re-run php artisan module:update-phpunit-coverage whenever you add, remove, enable, or disable a module. Make sure your module tests are part of a PHPUnit test suite; see Run the tests of a module.
Check the result
Section titled “Check the result”Open phpunit.xml and confirm ./Modules/Blog/app/ appears under <source><include>. The coverage output lists files under Modules/Blog/app.
If the command exits with a non-zero status, check the exit code reference in module:update-phpunit-coverage.