Skip to content

Instantly share code, notes, and snippets.

@jqtrde
Forked from runlevel5/gist:4172582
Created March 16, 2016 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jqtrde/d673ada9b30e12fe7245 to your computer and use it in GitHub Desktop.
Save jqtrde/d673ada9b30e12fe7245 to your computer and use it in GitHub Desktop.
Travis + Parallel tests with Build Matrix for Rails + Cucumber

Read more at http://about.travis-ci.org/blog/2012-11-27-shipping-the-new-travis-ci-ui-for-pro/

In my app, I do not use default rails integration tests, instead I use cucumber for it. Due to the fact cucumber does not override rake test:integrations and must be execute separately. Below is a solution that I came up with to have your Travis running units + functionals + cucumber tests:

First creating a simple bash script at RAILS_ROOT/ci.sh:

#!/bin/bash

case $1 in
units) echo "Run units tests"
    bundle exec rake test:units
    ;;
functionals) echo "Run functionals tests"
    bundle exec rake test:functionals
    ;;
cucumber) echo "Run cucumber suite"
    bundle exec cucumber -t @success
    ;;
esac

and edit your .travis.yml:

env:
  - TEST_SUITE=units
  - TEST_SUITE=functionals
  - TEST_SUITE=cucumber
script:
  - ci.sh $TEST_SUITE

ci.sh will work out which test to run by looking up the TEST_SUITE env variable. Simple but works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment