Call us at (416) 850-2500 - Visit us at 639 Queen St. W, Suite 502, Toronto, Ontario M5V 2B7
  Posted by Oleg on December 16th, 2009

Remember Rcov?

Rcov helps to identify code that is not being being hit by your tests (or maybe some functions left behind after refactoring). It’s very easy to get it running as well:

$ sudo gem install rcov

Plug this rake task into /lib/tasks/rcov.rake

require 'rcov/rcovtask'

namespace :rcov do
  desc 'Measures test coverage using rcov'
  Rcov::RcovTask.new(:test) do |rcov|
    rcov.pattern    = %w(test/unit/**/*_test.rb test/functional/**/*_test.rb test/integration/**/*_test.rb)
    rcov.output_dir = 'rcov'
    rcov.verbose    = true
    rcov.rcov_opts << '--exclude "gems/*"'
    rcov.rcov_opts << '--rails'
  end
end

And finally run it:

$ rake rcov:test

It’s so easy you have no excuse not to have it.

Leave a Reply