Sunday, September 16, 2007

rcov: code coverage for Ruby and Rails rcov plugin

rcov reference
Install:
shell> sudo gem install -y rcov
How do I use it? What does it look like?
shell> rcov --help
shell> rcov test/*.rb

Rails Rcov Plugin:
Install:
./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).

No comments :