Plugins - Rails rcov

StarAdd to favorites

rails_rcov provides easy-to-use Rake tasks to determine the code coverage of your unit, functional, and integration tests using Mauricio Fernandez’s rcov tool.

Installation

First, install rcov from Mauricio’s web site [http://eigenclass.org/hiki.rb?rcov]. Make sure it’s on your system path, so that typing rcov on the command line actually runs it. THIS PLUGIN DOESN’T DO ANYTHING BESIDES GENERATE ERRORS UNLESS YOU INSTALL RCOV FIRST. RCOV CONTAINS ALL THE MAGIC, THIS PLUGIN JUST RUNS IT.

Second, install this plugin. If your project is source-controlled by Subversion (which it should be, really), the easiest way to install this is via Rails’ plugin script:

  ./script/plugin install -x http://svn.codahale.com/rails_rcov

If you’re not using Subversion, or if you don’t want it adding svn:externals in your project, remove the -x switch:

  ./script/plugin install http://svn.codahale.com/rails_rcov

Usage

For each test:blah task you have for your Rails project, rails_rcov adds two more: test:blah:rcov and test:blah:clobber_rcov.

Running rake test:units:rcov, for example, will run your unit tests through rcov and write the code coverage reports to your_rails_app/coverage/units.

Running test:units:clobber_rcov will erase the generated report for the unit tests.

Each rcov task can take a few options:

  rake test:units:rcov SORT=(name|loc|coverage)
  rake test:units:rcov SORT_REVERSE=(YES|Y|TRUE|T|1)
  rake test:units:rcov THRESHOLD=(INT)
  rake test:units:rcov NO_COLOR=(YES|Y|TRUE|T|1)
  rake test:units:rcov PROFILE=(YES|Y|TRUE|T|1)
  rake test:units:rcov SHOW_WARNINGS=(YES|Y|TRUE|T|1)

These options parallel the rcov options, so check the rcov documentation if this isn’t clear.

Running rake test:rcov will run the unit tests, functional tests, and integration tests sequentially via rcov, and output the results to your_rails_app/coverage/(units|functionals|integration).

Resources

Subversion

Blog

Credits

Written by Coda Hale .

Coda Hale

http://blog.codahale.com/2006/05/26/rails-plugin-rails_rcov/

http://svn.codahale.com/rails_rcov

Rails' (MIT)

  • Currently 4.3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Testing

Tags

Comments

Add a comment
Keegan Quinn 27 May 2007

I have a patch to rails_rcov which adds a working test:rcov task. It's posted on my blog:

http://keegan.sniz.net/articles/2007/05/27/showin-love-for-rails_rcov

Hope this helps!

Alexander 11 May 2007

I've the same problem as core. Windows XP, ruby 1.8.6, rails 1.2.3

Tadd Giles 5 May 2007

I'm seeing the same problem as core. test:rcov isn't showing as a task in rake --tests test:units:rcov is there as well as the others.

anonymous 28 Feb 2007

The codahale blog shows the correct way to pass command lines to rcov: http://blog.codahale.com/2006/05/26/rails-plugin-rails_rcov/

For example, to sort by coverage, and not use color output:

> rake test:units:rcov RCOV_PARAMS="--sort=coverage --no-color"

Be sure to quote all the rcov options together. For a list of options, use

> rcov --help

anonymous 28 Feb 2007

The options seem to do nothing for me. rake test:units:rcov produces the same as rake test:units:rcove SORT=coverage

Andrew Montgomery 21 Feb 2007

rake -T rcov reports:

rake test:functionals:clobber_rcov # Remove Rcov reports for functional tests rake test:functionals:rcov # Run all functional tests with Rcov to measure coverage rake test:integration:clobber_rcov # Remove Rcov reports for integration tests rake test:integration:rcov # Run all integration tests with Rcov to measure coverage rake test:plugins:clobber_rcov # Remove Rcov reports for plugin tests rake test:plugins:rcov # Run all plugin tests with Rcov to measure coverage rake test:recent:clobber_rcov # Remove Rcov reports for recent tests rake test:recent:rcov # Run all recent tests with Rcov to measure coverage rake test:test:clobber_rcov # Remove Rcov reports for test tests rake test:test:rcov # Run all test tests with Rcov to measure coverage rake test:uncommitted:clobber_rcov # Remove Rcov reports for uncommitted tests rake test:uncommitted:rcov # Run all uncommitted tests with Rcov to measure coverage rake test:units:clobber_rcov # Remove Rcov reports for unit tests rake test:units:rcov # Run all unit tests with Rcov to measure coverage

rake test:test:rcov seems to work fine

core 15 Feb 2007

rake test:units:rcov, test:functionals:rcov, and test:integration:rcov all run fine for me, but rake test:rcov seems to be broken:

rake aborted! Don't know how to build task 'test:rcov'

I'm using Rails 1.2 with rcov 0.7.0 on Ubuntu Edgy, which has Ruby 1.8.4.

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.
Recruiting software

Have a comment?