Restlet Client Test Scenarios

Restlet Client (formely known as DHC) is a powerful tool for calling APIs, but it also helps developers and testers validate API behavior. In particular, Scenarios let you build API tests that reflect real-life API usage. Designing test scenarios is simple and visual. Expressions can be used to chain requests and set expectations on responses.

Here’s a glimpse of a basic scenario that does some data validation on Paul Hallett’s Star Wars API:

Here’s the scenario to import into your Restlet Client so that you can quickly try this example.

Once test scenarios are defined in Restlet Client, chances are that you would like to integrate them as part of your Continuous Integration / Continuous Delivery pipeline. This is made possible by the Restlet Client Maven test runner.

You can export a runnable scenario by clicking on the “export to Maven” button. You’ll be offered an option to download a pre-configured Maven project to get started quickly. It’s composed of two files: the test scenario in the form of a JSON file and the Maven pom.xml configuration file.

By typing mvn test in your terminal, you’ll trigger the execution of your scenario on your computer:

In real life, you’ll probably want to have a single project storing all your test scenarios. You’ll find the same export options on Restlet Client projects.

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 files mentioned above: the JSON file containing your scenario and the pom.xml configuration file.

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

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:

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:

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 execution. 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.

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.


Interested in automating your API tests on Travis CI? Start now with a free trial of the Restlet Platform!

Leave a Reply

Your email address will not be published. Required fields are marked *