If you’re on win32, you can also find a pre-built rcovrt.so (which makes
code coverage analysis >100 times faster) in the above-mentioned pages.
rcov is a tool for simple code coverage analysis in Ruby. It features:
- fast execution: 20-300 times faster than previous tools
- multiple analysis modes
- more accurate coverage information through code linkage inference
- XHTML, plain text, ANSI-escaped text outputs
- convenient interface
What’s new in 0.3.0
A change summary can be found at
Even shorter summary:
rcov 0.3.0 introduces a number of features that simplify the analysis of
The new code coverage analysis mode, --test-unit-only, records
executed inside Test::Unit::TestCase(s). Another important addition is
ability to detect aliased source files: this was very needed to analyze
apps, where a file could get loaded under several different names, due
extensive usage of #require with relative paths.
* consolidate multiple references to the same underlying .rb file
(much needed for Rails)
* consider and/op operators
* honor --no-color in (rich) text mode
* output valid XHTML indices
Thanks (do tell if I forgot to list your name)
- identified and fixed backslash problem on win32 for generated
- made the index XHTML compliant
- consolidate multiple references to the same underlying .rb file
- pointed me to dynamic uses of the tracing hooks, provided the
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.