It is very important to know how well your application is tested. If you wrote all the tests by yourself, then you can probably guess it, but if there is a team or you are working on a relatively old project, guessing will not work. Fortunately, there is a way to generate code coverage reports using PHPUnit and Xdebug. This report gives information about how well the application is tested, which lines are being executed while running tests, and which are not.
As an example, we will generate a report for the Yii framework's core base classes.
The Yii framework core tests are not included into release distributions, so we need to get it from the GitHub.
Go to https://github.com/yiisoft/yii and either download code using the
ZIP
button or use git to clone it.In console, enter the following:
cd path/to/code/tests/ phpunit --coverage-html report framework/base
After the report is generated, go to the
path/to/code/tests/
report and open...