CRAP in PHPUnit 3.5
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:
12/01/2010 at 14:49 Permalink
Reply
13/01/2010 at 19:21 Permalink
Reply
18/01/2010 at 15:58 Permalink
Reply
04/02/2010 at 03:18 Permalink
I have just tried PHP_CodeCoverage package and it is working great.
Just what I needed :)
Thanks Sebastian
However I was wondering if this package is available from phpunit pear channel.
I tried to guess package name/version/state but without luck :/
--
Best regards
Reply
04/02/2010 at 03:39 Permalink
The first stable release (1.0.0) will coincide with the release of PHPUnit 3.5.
Reply
11/02/2010 at 14:10 Permalink
I've been digging around in the PHP_CodeCoverage code trying to figure out how I can get it working with Moodle and SimpleTest.
I am aiming to try and get our Moodle installation working with PHPUnit, but that is going to take a while (unless you have the automatic conversion scripts from SimpleTest->PHPUnit done, I see others have asked for this in the past and you have said it was something you where considering).
Is there any chance I could grab some time at some point to discuss this, or is there any simple test cases where you have PHP_CodeCoverage working using xdebug with some sample code that isn't PHPUnit.
If you could reply to my email (I guess you should be able to see the one I attached to this post) that would be great, but only if and when you have some spare time (as I know time is a precious!)
This would be great for the testing community in general. I know it would be running under something other than PHPUnit, but I'm guessing it should still be able to work as all it takes is the xdebug output and a list of files (white and blacklist I guess?)
Regards,
James Brisland
Reply