Coveralls Badges

Todays post will be covering Coveralls. This is the third post in my series on GitHub Badges.

In my last post I covered the hosted CI service TravisCI.  Once you get your code building in a ci system which automatically runs your tests, one of the next features you might look to add is code coverage reports. TravisCI does not directly support code coverage reports, but can integrate with Coveralls for this feature. You’ve likely seen badges linking to the Coveralls service, they look something like this:


As you can probably surmise, these badges indicate current test coverage. Coveralls originally only supported Ruby, but now supports several other languages.

Setting up a project in coveralls is pretty trivial. Once again, authentication is handled via Oauth using your GitHub account. Once you have authenticated with your GitHub account, you will have a page that looks something like this:

Screen Shot 2013-12-22 at 10.09.16 PM

Just flick the switch on for a repo and you will be linked to instructions for the remaining steps. For a Ruby project, you will have to add a line to your Gemfile like this:

<br />gem 'coveralls', require: false<br />

If you haven’t seen the ‘require => false’ option before, it just tell Bundler to install the gem and maintain dependencies, but not actually load it. You will need to add a couple of lines to the very beginning of your test_helper.rb to do that. Usually that will look like this:

<br />require 'coveralls'<br />Coveralls.wear!('rails')<br />

You can omit the argument to the Coveralls.wear! method call if your project is non-rails. Finally you will need to tell coveralls about your ci server. This is done in a .coveralls.yml file added to the root of your project. In many cases this may just be a single line like:

<br />service_name: travis-ci<br />

That’s pretty much all there is to it. After that, if you watch the logs from a travis build, you will see it is sending coverage data to coveralls. Go you your coveralls page and you can see file by file and line by line coverage information.

Screen Shot 2013-12-22 at 10.25.23 PM

File Coverage

Screen Shot 2013-12-22 at 10.25.52 PM

Line by Line Coverage

As with most other codebase services behind GitHub badges, the service is free for public repos and available for a fee to private repos. At the time of this writing, pricing for a single private repo was $4.99/month and a 10 repo plan was $24.99/month.

One response to “Coveralls Badges”

Leave a Reply to Github Badges | Byron's Code Blog Cancel reply

Your email address will not be published. Required fields are marked *