Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sebastian Bergmann's Blog:
CRAP in PHPUnit 3.5
Jan 12, 2010 @ 17:14:03

As Sebastian Bergmann mentions in his latest post, he's changed up how the code coverage functionality is handled in PHPUnit so that he can add something new - CRAP.

PHP_CodeCoverage is a component that provides collection, processing, and rendering functionality for PHP code coverage information. [...] 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.

Your code's CRAP (Change Risk Analysis and Predictions) scoring combines the idea of cyclomatic complexity and code coverage statistics to try to guess at how difficult any given piece of code would be to maintain. You can see an example here - the lower the number the better.

tagged: crap cyclomatic complexity codecoverage phpunit unittest

Link:

Jacob Santos' Blog:
What is your C.R.A.P. Index?
Aug 07, 2007 @ 16:57:00

In relation to a recent announcement from Sebastian Bergmann about the inclusion of Cyclometic Complexity testing in the upcoming PHPUnit release, Jacob Santos has taken a look at its use - find the C.R.A.P. of a process.

The Change Risk Analysis and Predictions (CRAP) index is to give some idea how difficult it would be to maintain the code base. It is not to be used in evaluating how "beautiful" the code is.

He had to modify things slightly in PHPUnit to get it to work with entire files/functions, but it was still simple to use the testing software to create each file's CRAP index. For his examples, he chose the WordPress code and includes the code he used for the tests - two functions: getCCLevel and getCrapIndex. The results of the report are also included.

tagged: phpunit crap index cyclomatic complexity unittest phpunit crap index cyclomatic complexity unittest

Link:

Jacob Santos' Blog:
What is your C.R.A.P. Index?
Aug 07, 2007 @ 16:57:00

In relation to a recent announcement from Sebastian Bergmann about the inclusion of Cyclometic Complexity testing in the upcoming PHPUnit release, Jacob Santos has taken a look at its use - find the C.R.A.P. of a process.

The Change Risk Analysis and Predictions (CRAP) index is to give some idea how difficult it would be to maintain the code base. It is not to be used in evaluating how "beautiful" the code is.

He had to modify things slightly in PHPUnit to get it to work with entire files/functions, but it was still simple to use the testing software to create each file's CRAP index. For his examples, he chose the WordPress code and includes the code he used for the tests - two functions: getCCLevel and getCrapIndex. The results of the report are also included.

tagged: phpunit crap index cyclomatic complexity unittest phpunit crap index cyclomatic complexity unittest

Link:


Trending Topics: