phpunitHow to generate a coverage report with PHPUnit?
PHPUnit provides a way to generate a coverage report to measure the amount of code covered by tests. To generate a coverage report, the --coverage-html
option must be used when running the tests.
phpunit --coverage-html ./report
This will generate a coverage report in the ./report
directory. The report will contain information about the lines of code executed, classes, methods, and functions.
Code explanation
--coverage-html
: This option is used to generate a coverage report../report
: This is the directory where the report will be generated.
Helpful links
More of Phpunit
- How to show warnings in PHPUnit?
- How to skip a PHPUnit test?
- How to run tests in parallel with PHPUnit?
- How to stop PHPUnit on failure?
- What are PHPUnit required extensions
- How to mock a query builder with PHPUnit?
- How to run all PHPUnit tests?
- How to install PHPUnit with a PHAR file?
- How to use named arguments in PHPUnit?
- How to mock with PHPUnit?
See more codes...