PHPUnit integrates PHPCoverage and can generate test coverage reports directly through the command line when running tests.
Previous versions of PHPUnit also required the xdebug plug-in to generate reports, but after PHPUnit 8x, you can install the PCOV plug-in as a code coverage driver.
> apt install php7.4-pcov
Then install the pcov code package
> composer require --dev pcov/clobber:^2.0
This completes all the basic installation, and then starts to generate the test report using the command line
> ./vendor/bin/phpunit --coverage-html tests/html --coverage-filter app/models --bootstrap tests/bootstrap.php tests/model/video/block
--coverage- The html option tells phpunit which folder to store the generated html files
--the coverage-filter option tells phpunit which folder to analyze the code under which folder
generated The coverage report is as shown in the figure:
Quote:
https://www.lambdatest.com/blog/phpunit-code-coverage-report-html/