I'm working on a Laravel 10 (with PHPUnit 10 and Xdebug 3) project in which business logic has been split into modules: at the app/ directory level is the modules/ directory where resides modules code (i.e. providers, migrations, models, etc).
.
├── app <-
├── bin
├── bootstrap
├── config
├── database
├── docker
├── environments
├── lang
├── modules <-
├── node_modules
├── public
├── resources
├── routes
├── storage
├── tests
└── vendor
In phpunit.xml I added the new directory source as follow:
<source>
<include>
<directory>app</directory>
<directory>modules</directory>
</include>
</source>
So now the HTML code coverage output correctly list it:
Problem is: its coverage is always at 0% when running tests for modules business logic.
I never used PHPUnit code coverage attributes since I never needed them, every other project I worked on generated correct code coverage without them.
Do I need to add those attributes for source files out of app/ directory?
Update #1
Adding CoversClass(TestedClass::class)] attribute to a module test class did not solve the problem, modules/ code coverage percentage is still 0.
Update #2: Xdebug not being set to coverage
I'm checking if Xdebug mode is correctly set to coverage during tests, and using a simple dd(getenv()) inside of a test show that XDEBUG_MODE=off.
The application is running on docker and the container mount a custom 99-php.ini with the entry xdebug.mode=coverage, so I assume that the '99' makes it the least important between the .ini files being loaded, thus its config do not overwrite an existing xdebug.mode=off in another file.
I added the entry <env name="XDEBUG_MODE" value="coverage" /> to phpunix.xml php section, but still the test output still show off as xdebug mode.
Finally I tried to manually set env variable in container with XDEBUG_MODE=coverage and it looks working (test output correctly display an entry XDEBUG_MODE=coverage from getenv()), problem is modules directory still get a 0% code coverage.

./appand./modules? ref docsappandmodulespaths, as I said html output correctly list every subfolder and file in both, moreover forappis reported the percentage for the little amount of code coveredphp -d pcov.enabled=1 -d pcov.directory=. -dpcov.exclude="~vendor~" \ vendor/bin/pest --coverage-html=build/coverageI've seen here ref they have a case with 0% cov