rcov 0.7.0 can aggregate code coverage and defsite/callsite data collected in successive runs. This is useful when you want to obtain a global coverage rate
but your tests are split into several parts, for instance units,
functionals and integration, as happens in Rails.
Here's how you'd define coverage tasks for unit, functional and integration tests
under the test:coverage namespace, as well as a test:coverage task that runs them all
and yields an aggregate coverage rate:
require 'rcov/rcovtask'
namespace :test do
namespace :coverage do
desc "Delete aggregate coverage data."
task(:clean) { rm_f "coverage.data" }
end
desc 'Aggregate code coverage for unit, functional and integration tests'
task :coverage => "test:coverage:clean"
%w[unit functional integration].each do |target|
namespace :coverage do
Rcov::RcovTask.new(target) do |t|
t.libs << "test"
t.test_files = FileList["test/#{target}/*_test.rb"]
t.output_dir = "test/coverage/#{target}"
t.verbose = true
t.rcov_opts << '--rails --aggregate coverage.data'
end
end
task :coverage => "test:coverage:#{target}"
end
end
All you have to do to combine data from multiple runs is to add
--aggregate FILE
so that the data from previous runs saved in FILE is loaded (if FILE doesn't exist then
history will be empty), merged with the newer information and stored back into FILE:
Read more...
Read: rcov 0.7.0: code coverage and callsite/defsite data aggregation across multiple runs