Source code, additional information, screenshots… available at
rcov is a tool for simple code coverage analysis in Ruby. It improves on
the better known coverage in a number of ways:
- 20-300 times faster: typically, the program being inspect runs only ~3
times slower than without rcov (i.e. not 200 times slower as with
some other tools)
- more convenient interface
- prettier output (since 0.2.0)
- more accurate coverage information through code linkage inference
- additional features like bogo-profile mode, colorblind-friendliness…
Code coverage shouldn’t be abused (in few words, C0 coverage guarantees
nothing) but it’s still useful for testing: it will at least tell you
your tests need more work, and most importantly where.
What’s new in 0.2.0
A change summary is available at
Visible changes since 0.1.0:
- improved HTML output (cleaner and more readable) — using xx under
- textual output: execution counts or code decorated with ANSI sequences
- more convenient interface: run several scripts/tests in one go,
The last version is available at
How do I use it? What does it look like?
Just use rcov to run your program (instead of ruby), and a number of
files with the code coverage information will be generated, e.g.
will execute all the .rb files under test/ and generate the code
under coverage/. rcov can also operate in “bogo-profiling mode”
and output the relevant information in alternative formats (for the time
being, plain text with execution count annotations and colored text).
for more information.
See http://eigenclass.org/hiki.rb?rcov (once again) for screenshots.
The (undecorated) textual output with execution count information looks
$ rcov --no-html -t b.rb
a, b, c = (1…3).to_a |
10.times do |
a += 1 |
20.times do |i| |
b += i |
b.times do |
c += (j = (b-a).abs) > 0 ? j : 0 |
rcov is released under the terms of Ruby’s license.
rcov includes xx 0.1.0, which is subject to the following conditions:
ePark Labs Public License version 1
Copyright © 2005, ePark Labs, Inc. and contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
this list of conditions and the following disclaimer in the
and/or other materials provided with the distribution.
- Neither the name of ePark Labs nor the names of its contributors
used to endorse or promote products derived from this software
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.