# Rails Testing Tips: Code Coverage

> Using rcov to track test coverage in a Ruby on Rails project

- Author: Curtis Miller
- Published: 2007-01-24
- Categories: rails, testing
- Canonical URL: https://millarian.com/posts/ruby-on-rails-code-coverage/

I realized that I would need to track my progress over time and began looking for a code coverage tool for Ruby on Rails. It did not take me long to find the coverage tool (dead link: http://rubyforge.org/projects/aeditor/). However, coverage states that they are not making any changes and that [rcov](http://eigenclass.org/hiki.rb?rcov) is better. I checked out rcov and it is pretty sweet and easy to use.

It replaces the command line invocation you would normally use to execute your tests and outputs the results as HTML into a coverage directory in your project. It is as easy as executing

```
rcov test/**/*.rb
```

to execute all of your tests and then browse the coverage directory with your favorite browser (i.e., Firefox).

If you are in the market for a free, easy to use code coverage utility for Ruby on Rails, I suggest rcov.

To install coverage

```
sudo gem install coverage
```

To install rcov

```
sudo gem install rcov
```
