rcov 0.7.0: code coverage and callsite/defsite data aggregation across multiple runs
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:
rm coverage.data rcov --aggregate coverage.data test/unit/*.rb rcov --aggregate coverage.data test/integration/*.rb
coverage.data will hold quite a lot of information: all the Ruby code that was executed, execution counts and coverage data for all files.
Download
The tarball with the latest sources is available here. You can also get it via rubyforge, or install with gem install rcov (the packages haven't been propagated to the mirrors as of 9:34 UTC, allow some more time).
User-visible changes since 0.6.0 (2006-06-12)
Features
- coverage/callsite data from multiple runs can be aggregated (--aggregate)
Bugfixes
- the SCRIPT_LINES__ workaround works better
- fixed silly bug in coverage data acquisition (line after the correct one marked in some situations)
- avoid problems with repeated path separators in default ignore list, based on rbconfig's data
Thanks
Thomas Leitner:
- reported that the SCRIPT_LINES__ workaround did not always work
Assaph Mehr:
- beta-tested 0.7.0 and found a bug in --aggregate (missing files)
Ryan Kinderman:
- suggested that -Ipath be passed to ruby instead of rcov in RcovTasks
- 49 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/206760
- 23 http://rashkovskii.com/articles/2007/1/10/continuous-integration-cerberus
- 15 http://rubyforge.org/forum/forum.php?forum_id=8371
- 15 http://rashkovskii.com/tags/rake
- 11 http://www.artima.com/forums/flat.jsp?forum=123&thread=170887
- 10 http://anarchaia.org
- 8 http://www.ruby-forum.com/topic/75934
- 8 http://www.artima.com/buzz/community.jsp?forum=123
- 6 http://www.rashkovskii.com/tags/rake
- 4 http://planetruby.0x42.net
Keyword(s):[blog] [ruby] [frontpage] [rcov] [0.7.0] [release] [code] [coverage]
References:[rcov: code coverage for Ruby]