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:testdonamespace:coveragedodesc"Delete aggregate coverage data."task(:clean){rm_f"coverage.data"}enddesc'Aggregate code coverage for unit, functional and integration tests'task:coverage=>"test:coverage:clean"%w[unit functional integration].eachdo|target|namespace:coveragedoRcov::RcovTask.new(target)do|t|t.libs<<"test"t.test_files=FileList["test/#{target}/*_test.rb"]t.output_dir="test/coverage/#{target}"t.verbose=truet.rcov_opts<<'--rails --aggregate coverage.data'endendtask:coverage=>"test:coverage:#{target}"endend
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: