Add an rcov c0 code coverage threshold to your cc.rb build
Okay, you use rcov through metric_fu to measure your test code coverage. If you can’t compile it at least you know your code doesn’t throw run time syntax errors, right? All of it? Yeah… well, me neither. But I’m trying to get better and this is my technique for that.
Never take a step backwards. Fail your builds if the test coverage drops below where you’re currently at.
Here’s a rake task to fail the build if it drops out below a set threshold.
Add it to your lib/tasks folder in your rails app.
As you increase coverage update the threshold, treat that threshold like a ratchet, a notch of movement each time but always in the same direction.
I’m sure this is extensible to other metric_fu metrics too.
p.s., I’m very open to hearing a better way of doing this. I couldn’t get any joy from the metric_fu mailing list so hacked this together. Surely there must be a better way?