Skip to content

rcov (0.9.9 java) - coverage aggregation issue #76

leckylao opened this Issue May 24, 2011 · 8 comments

7 participants



I am using jruby-1.6.1 with rcov (0.9.9 java) to run coverage report for my cucumber features and rspec tests. Everything works fine except it's not aggregating the data in the report. And there's no errors.

All the tests pass. And It's not aggregating the data as I can tell by seeing the controller get higher coverage with cucumber but later get dropped in the final report.

Here's the code. Please help.

desc 'Measures Cucumber features coverage using rcov' do |t|
  t.rcov = true
  t.rcov_opts = %w{--aggregate report/ --text-report --rails}
  t.rcov_opts << "-o report/coverage-cucumber-#{"%d_%m_%Y_%I_%M_%p")}"

desc 'Measures Rspec coverage using rcov' do |t|
  t.spec_files = FileList['spec/**/*_spec.rb']
  t.rcov = true
  t.rcov_opts = %w{--aggregate report/ --text-report --rails}
  t.rcov_dir = "report/coverage-rspec-#{"%d_%m_%Y_%I_%M_%p")}"

desc "Run unit tests, specs and features to generate aggregated coverage"
task :all do |t|
  rm "report/" if File.exist?("report/")
tatyree commented Jul 12, 2011

I'm seeing exactly the same thing with Jruby 1.6.2 and 0.9.9. I've created a example app to illustrate the problem. You can clone it here:

git clone git://

I've included the coverage reports from my last run, which I think was cucubmer_first. I've also included screenshots of example outputs from both runs. If you don't want to clone the example, you can see them in the README:

Basically, it just doesn't seem to be aggregating the results at all. Whichever set of tests get run last are the ones the coverage report is based on.

tatyree commented Jul 12, 2011

I just checked it on 1.8.7 and it behaves as expected: 100% coverage regardless of the run order.


+1 -- I'm seeing this too.


+1 with plain ruby 1.8.7 patch 334

abedra commented Jan 20, 2012

I cloned the repo and ran both tasks. For both runs I only get 63.6% coverage, no matter which task I use.

tomgi commented Feb 1, 2012



I have the same problem with rcov and JRuby (tested 1.6.4 and 1.6.7 recently).

Some quick investigation shows the problem is with loading the aggregate data (the gzipped, marshal serialization). Attempting to load the aggregate data outside of rcov with

require 'rubygems'
gem 'rcov'
require 'rcov'
require 'zlib'

file = 'aggr.rcov' {|gz| old_data = Marshal.load(gz) }

leads to

ArgumentError: dump format error(p)
      load at org/jruby/
  __file__ at load_aggr.rb:7
    (root) at load_aggr.rb:7

As a test, I hacked the rcov script to not gzip the marshalled data, and it then works correctly.


As a temporary work-around for those that need this feature in JRuby right now (like me), I have forked version 0.9.11 of rcov and disabled gzipping of aggregate data. See the jruby_tmp branch at You can use this, for example, by specifying in your Gemfile:

gem 'rcov', '', :git => "git://", :branch => 'jruby_tmp'

When I have some more time, I intend to investigate further the problem with gzip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.