Coveralls

Coveralls is a hosted analysis tool, providing statistics about your code coverage.

Configuring your Travis CI build to send results to Coveralls always follows the same pattern:

  1. Add your repository to Coveralls.
  2. Configure your build to install the Coveralls library for the programming language you’re using.
  3. Add Coveralls to your test suite.
  4. If you’re using Travis CI for private repos, add service_name: travis-pro to your .coveralls.yml.

We’ll show you how to do this for Ruby in the following example.

Using Coveralls with Ruby #

Using Coveralls with Ruby on Travis CI is one of the configurations Coveralls support out of the box have documentation for.

1. Add your repository to Coveralls #

  1. Sign in to Coveralls with your GitHub account.
  2. Click ADD REPOS in the menu.
  3. Click the Add your repository to Coveralls button next to your repository.

2. Install the Coveralls Gem #

Add the Coveralls Gem to your Gemfile:

# ./Gemfile

gem 'coveralls', require: false

You might need to update your Gemfile.lock as well.

3. Add Coveralls to your test suite #

Add Coveralls to the top your test suite, before you require any application code:

# ./spec/spec_helper.rb
# ./test/test_helper.rb
# ..etc..

require 'coveralls'
Coveralls.wear!

After those three steps, the next time you push a commit, you’ll be able to look up your code coverage statistics!

Coveralls and private repositories #

If you’re using Coveralls with Travis CI for private repositories, edit .coveralls.yml:

service_name: travis-pro

Using Coveralls with other languages #

Coveralls have documentation for many other programming languages:

Using Coveralls with Docker builds #

If you’re using Docker in builds, ensure that the necessary environment variables are exposed to the container:

docker exec -e TRAVIS_JOB_ID="$TRAVIS_JOB_ID" -e TRAVIS_BRANCH="$TRAVIS_BRANCH" ...