Code Coverage Dashboard

Almost a year ago I started to factor out all the code that deals with code coverage in PHPUnit and put it into a separate component. The name of this component is PHP_CodeCoverage.

PHP_CodeCoverage is a library that provides collection, processing, and rendering functionality for PHP code coverage information. Its architecture has support for multiple backends for collecting code coverage information (currently only support for Xdebug is implemented) and for reporting code coverage information (for instance using Clover XML or as an HTML report).

As mentioned earlier, the HTML report that is generated by PHP_CodeCoverage shows the CRAP Index software metric for each function or method. Today I built on this earlier development and added a "dashboard view" to the HTML report that shows the following software metrics:

  • Class Coverage Distribution: This is a bar chart that shows how many classes have 0%, ..., 100% code coverage
  • Class Complexity: This is a scatter chart that shows the coverage (X axis) and the complexity (Y axis) of the classes
  • Top Project Risks: This is list of the classes with the highest CRAP Index
  • Least Tested Methods: This is the list of the least tested methods

You can see an example of the dashboard view below:

PHP_CodeCoverage Dashboard View