Run your API tests on Travis CI

Travis CI

This tutorial assumes you know how to launch Restlet Client tests from CLI. If you don't know, please have a look at the documentation first.

Now let's run our API tests on Travis CI! Travis CI is a popular tool helping development teams to continuously building and delivering apps with confidence. It’s free for open-source projects. Just login with your Github account and you’re set.

Running your scenarios on Travis CI

First thing to do in order to run your scenario on Travis CI is to push it to a Github repository. Make sure you push the 2 test files:

  • the JSON file containing your scenario
  • the pom.xml configuration file

Note: Restlet Client now has a GitHub integration to help you push your tests files to GitHub in a whim. You can learn more about this feature here.

Second step is to go to your profile page on, find your Github repository and switch it on:

Switch GitHub project on in Travis

The third and final step is to create a .travis.yml file for Travis configuration. Let’s start with a simple configuration:

language: java
jdk: oraclejdk8
install: true # skipping the default Travis install step
- mvn test

After pushing your .travis.yml file to your Github repository, you should see the build running on Travis-CI:

Travis build setup

From now on, each time you push to your Github repository, a build will be triggered on Travis CI, and will run your test scenarios!

Setting up your license key

Test scenario automation through Maven is a paying feature, so you’ll be asked to enter your license key. Your license key is private to you and should not be published on a Github repository. A simple way to securely manage your key is to add it as an environment variable in Travis CI settings :

Travis Environment Variables

You can find your license key on the Restlet Client billing page. You’ll then be able to access your key in your build script and pass it to Maven:

- mvn test -Dlicense_key=$LICENSE_KEY

This argument can then be used in your pom.xml configuration:


See an example of .travis.yml and pom.xml files.

Another valid option would be to store it as an encrypted string in your .travis.yml file.

Automating scenario execution in Travis CI

Travis CI offers the ability to schedule job executions . It can be very practical if your team is doing nightly deployment. That way you’ll be ensuring that the latest version of your API, deployed each night on a staging environment, does not break your API contract.

Travis Cron

Travis report

Another approach is to fire your API tests after each successful deployment of your API. See Travis CI documentation on how to customize the build and run commands after deploying .

It’s also good to know that you can trigger a Travis build by calling the Travis API .