rcov is a code coverage tool for Ruby I originally wrote 2 years ago.
It improves on the better known
coverage in a number of
points:
20-300 times faster
more accurate coverage information through code linkage inference using simple heuristics
slightly more convenient interface (arguably; work on this is probably needed)
additional features like bogo-profile mode, colorblind-safeness...
Code coverage shouldn't be abused (in few words, C0 coverage guarantees
nothing) but it's still useful for testing: it will at least tell you when
your tests need more work, and most importantly where.
What does it look like?
Just use rcov to run your program (instead of Ruby), and a number of XHTML
files with the code coverage information will be generated.
For example, given
srand(0)c=0d=110.timesdo|i|ifrand%(i+10)c+=id+=1endendputs"blergh"ifc>4*d# stuffputs"yep"elseputs"nope"# more stuffendputs"Done: #{c+d}"