rcov 0.4.0 is really feature-packed, and (hopefully) less buggy than previous
releases. This can be ascribed in large part to the use of rcov on itself to
achieve better test coverage.
Download it from rcov: code coverage for Ruby.
The looks
Starting with the most obvious changes, the XHTML output looks much better
now with the new color-scheme. Plain text output formats have also improved
considerably. Take a look at this sample report and compare the following screenshots to those from version 0.2.0:
Scriptability and automation with Rake
rcov 0.4.0 is much easier to use from external scripts, and invoking rcov
from your Rakefile takes no effort with the included Rcov::RcovTask; it can
take as little as:
require 'rcov/rcovtask'
Rcov::RcovTask.new
Really! This creates a task named "rcov" which will run the tests matching
test/test*.rb and create a XHTML report. And a nice textual report on
stdout). And a clobber_rcov task, which the main clobber target will depend
on, to delete the former.
However, sometimes that lone Rcov::RcovTask.new will not suffice; this would
be a more realistic example:
# if you don't like the default description
desc "Analyze code coverage of the unit tests."
Rcov::RcovTask.new do |t|
# change the glob pattern in the next line
t.test_files = FileList['test/test*.rb']
t.rcov_opts << "--sort coverage" # sort by increasing coverage rate
end
By default, RcovTasks will show a text report resembling