Aggregating RCov reports over all tests

This article is deprecated.I've marked this article as deprecated. It is either because the gem or plugin discussed in this article is no longer maintained, or I've changed my opinion on it. This article is here only as an historic reference.

Rcov all the way

I installed the rails_rcov plugin to see the coverage like any good programmer ;-) But when I want to know what all the tests combined produce in coverage, it just produced the coverage reports of each individual test (units, functionals and integration) and replacing each with one another. I am not a briliant googler, and when I couldn't find the answer in time, I decided to make my own rake task for it. Here it is:

namespace :test do
  desc "Run all tests at once through rcov."
  task :rcov do
    test_files = FileList['test/**/*_test.rb']
    output_dir = File.expand_path("./coverage/all/")
    command = "rcov -o \"#{output_dir}\" --rails --sort=coverage -T -x \"gems/*,rcov*,lib/*\" \"#{test_files.join('" "')}\""
    puts command
    puts `#{command}`
    puts "View all results at <file://#{output_dir}/index.html>"
  end
end

Now, it doesn't take any argument yet, but it works quite all right.

comments powered byDisqus