Skip to content
Code coverage for Ruby 1.9 with a powerful configuration library and automatic merging of coverage across test suites
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



SimpleCov is a code coverage analysis tool for Ruby 1.9. It makes use of Ruby's built-in Coverage library, wrapping it's results in a object-oriented manner. It also adds some sugar like filtering (so the coverage of used gems is not taken into account) and grouping (to check coverage on your Rails models for instance).

Though it ships with a basic formatter, it isn't particularily useful by itself, so you're going to need a dedicated formatter library - check out simple_cov-html for that!

Thanks to Aaron Patterson ( for the original idea for this!

Example config for Rails 3 (using HTML formatter)

Update your Gemfile with this and do a bundle install:

group :test do
  gem 'simple_cov', '>= 0.1.0'
  gem 'simple_cov-html', '>= 0.1.0'

Then, add the following to your Rails test/test_helper.rb (right at the top, line 00):

require 'simple_cov'
SimpleCov.start do
  add_filter do |src|
    !(src.filename =~ /^#{Dir.getwd}/)

  add_filter '/test/'

  add_group 'Controllers', 'app/controllers'
  add_group 'Models', 'app/models'
  add_group 'Helpers', 'app/helpers'
  add_group 'Configs', 'config/'
  add_group 'Libraries', 'lib'
  add_group 'Plugins', 'vendor/plugins'

Now, when running rake test you'll get a coverage/ folder inside your app's root where you can browse your code coverage.


  • Improve on tests (integration tests)

  • Add adapters, so i.e. SimpleCov.start 'rails' becomes possible and uses the above presets without the neccessity for manual config

  • Allow dumping and importing of results

  • Allow merging of discrete results (so cucumber & default tests can be analyzed together, i.e.)

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.


Copyright © 2010 Christoph Olszowka. See LICENSE for details.

Something went wrong with that request. Please try again.