CRAP in PHPUnit 3.5

Sebastian Bergmann » 12 January 2010 » in New Features » 6 Comments

For the upcoming PHPUnit 3.5, I have factored out all code that is related to code coverage and put it into a separate component: PHP_CodeCoverage.

PHP_CodeCoverage is a component that provides collection, processing, and rendering functionality for PHP code coverage information. It makes PHPUnit's mature code coverage functionality available outside of PHPUnit.

Having all code that deals with code coverage in a separate component allows for easier development and better testing. The first result of these improved development conditions is a small new feature that I recently implemented, the support for the CRAP metric.

From crap4j.org:

The CRAP (Change Risk Analysis and Predictions) software metric [has] a mildly offensive metric name [and helps] to help protect you from truly offensive code.

The CRAP metric combines cyclomatic complexity and code coverage from automated tests (e.g. [PHPUnit] tests) to help you identify code that might be particularly difficult to understand, test, or maintain — the kind of code that makes developers say: “This is crap!” or, if they are stuck maintaining it, “Oh, crap!”.

The screenshot below shows how the CRAP metric is reported in the HTML code coverage report:

Code Coverage Report
Defined tags for this entry: , , ,

PHPUnit and Software Metrics

Sebastian Bergmann » 03 August 2007 » in New Features » 0 Comments

The upcoming 3.2 release of PHPUnit adds a couple of software metrics to the data that is stored in PHPUnit's test database. Below is a list of the metrics that are calculated and collected:The example below shows how you can access, for instance, the Cyclomatic Complexity information for all methods of a project.

Continue reading "PHPUnit and Software Metrics"

Defined tags for this entry: , , , ,