Easy rcov with Test::Unit and Rails 2 »

Created at: 01.02.2010 14:23, source: A Fresh Cup, tagged: Rails Articles rails rcov testing

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.


more »