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:
- Add your repository to Coveralls.
- Configure your build to install the Coveralls library for the programming language you’re using.
- Add Coveralls to your test suite.
- 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 #
- Sign in to Coveralls with your GitHub account.
- Click ADD REPOS in the menu.
- Click the 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:
- C / C++
- D
- Elixir
- Erlang
- Fortran
- Go
- Haskell
- Java
- Javascript & Node
- Julia
- Lua
- OCaml
- Objective C
- PHP
- Python
- R
- Ruby / Rails
- Swift
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" ...