A Fresh Cup is Mike Gunderloy's software development weblog, covering Ruby on Rails and whatever else I find interesting in the universe of software. I'm a full-time Rails developer and contributor, available for long- or short-term consulting, with solid experience in working as part of a distributed team. If you'd like to hire me, drop me a line. I'm also the author of Rails Rescue Handbook and Rails Freelancing Handbook.

Navigation
« Double Shot #639 | Main | Double Shot #638 »
Monday
Feb012010

Easy rcov with Test::Unit and Rails 2

Yesterday, I needed test coverage numbers for an application using Rails 2.3 and plain old Test::Unit (still my test framework of choice). This proved to be a good deal more difficult than I expected: there are so many forks of the original rcov code, and so much disparate advice on how to get it hooked up, that I spent a great deal of unprofitable time reading before I got the right combination. Hopefully this short list will save you from doing the same:
  1. Install the relevance-rcov gem. This is the stable and maintained fork.
  2. Install the commondream rcov_plugin. This has the best set of working rake tasks I've found.
  3. Add coverage/* and test/coverage/* to your .gitignore.
  4. Run rake test:coverage to generate coverage results.
  5. Open /coverage/index.html in your project to view the results.

Reader Comments (4)

You can now just install rcov (from gemcutter), since github stopped building gems. relevance-rcov is *rcov* on gemcutter.

February 1, 2010 | Unregistered CommenterChad Humphries

Thanks Chad! Even simpler.

February 1, 2010 | Unregistered CommenterMike Gunderloy

Yeah this had been a source of confusion to many, and although I had it working through google-fu, it's nice to read this post so you can keep in mind the versioning issues.

February 1, 2010 | Unregistered CommenterAlex Hoggett

Thanks for the post, helped me get going with rcov and testunit!

February 14, 2010 | Unregistered CommenterNola

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>