Testing
Is your code C.R.A.P.?
Oct 9, 2007Just got a link this morning to the C.R.A.P. metric and the crap4j Eclipse plugin. This humourously-named approach mixes up cyclomatic complexity and code coverage to give a number that is your code's CRAP index. Generally speaking, you can lower your CRAP index either by adding automated tests or by refactoring to reduce complexity, or both.
Apparently crap4j can also estimate your CRAP Load (we've beaten this one to death - ed.), in which it gives an indication of how many tests you will need to write to reduce the CRAP index to less than an arbitrary bar of 30.
Update: tried it out, and it seems interesting - I can understand the concepts immediately and it has an amusing toilet paper icon on the menu. Here's a screenshot of the CRAP Report that it produces.
In the case of this anonymous component, you can see that the crapometer weighs in at 14.91% - an artitrary figure that tells me that a little over one in seven of the methods in the component are, well, crappy.
The CRAP Load figure above hints that maybe about 14 tests would do the trick in reducing the CRAP figure of a complex method with 0% coverage.