Travis

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.

Use Coveralls with Ruby #

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

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.

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.

Add Coveralls to your test suite #

Add Coveralls to the top of 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

Use Coveralls with other languages #

Coveralls have documentation for many other programming languages:

Use 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" ...