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 skip a PHPUnit test?
- How to run all PHPUnit tests?
- How to use Faker with PHPUnit?
- How to log to the console with PHPUnit?
- How to generate a JUnit report in PHPUnit?
- How to use the PHPUnit Framework TestCase?
- How to show warnings in PHPUnit?
- How to increase memory limit in PHPUnit?
- How to assert that key exists in an array using PHPUnit?
- How to group tests in PHPUnit?
See more codes...