9951 explained code solutions for 126 technologies

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

Edit this code on GitHub