Using Runscope and CodeShip For API testing

2 minute read

About Runscope

Runscope is an API testing and monitoring tool that can be used with continuous integration and delivery services like CodeShip to test and validate your web applications.

By using Runscope you can ship more reliable code for your teams and your customers.

The Runscope documentation provides a great guide to getting started, and the instructions below have more information on integrating with CodeShip.

CloudBees CodeShip Pro

Setting Your Access Token

To run your Runscope API tests on CodeShip, you will need to add your Runscope Access Token to your encrypted environment variables that you encrypt and include in your codeship-services.yml file:

You can get your access token from your Runscope settings.

Installing Runscope Dependencies And Script

After setting your personal access token, you will need to build a service in your codeship-services.yml file with the Runscope dependencies installed.

Runscope distributes these dependencies through pip, so you will need to be sure your service also has Python and Pip installed.

To install the dependencies you need, you can add the following to your service’s Dockerfile:

RUN pip install -r https://raw.githubusercontent.com/Runscope/python-trigger-sample/master/requirements.txt

Once you have the dependencies installed, you can add another line to your service’s Dockerfile to install the Runscope script itself:

RUN wget https://raw.githubusercontent.com/Runscope/python-trigger-sample/master/app.py

Note again that your service must be able to use wget for the above command to execute.

Triggering Runscope During A Build

To run the Runscope script and execute your tests during your build, you can use the Runscope script you installed via your codeship-services.yml file in a step called via your codeship-steps.yml file:

- name: Runscope service: app command: runscope.sh

Inside of the runscope.sh file, you can call the Runscope script with the following command:

python app.py https://api.runscope.com/radar/your_test_trigger_id/trigger?runscope_environment=your_runscope_environment_id

Note that you will need to change the URL to reflect the actual Trigger URL you have configured in Runscope.

CloudBees CodeShip Basic

Setting Your Access Token

To run your Runscope API tests on CodeShip, you will need to add your Runscope Access Token to your CodeShip project’s environment variables:

You can get your access token from your Runscope settings.

Installing Runscope Dependencies And Script

After setting your personal access token, you will need to install the Runscope dependencies and the Runscope script in your project’s setup commands.

In your setup commands, add the following:

pip install -r https://raw.githubusercontent.com/Runscope/python-trigger-sample/master/requirements.txt

and

wget https://raw.githubusercontent.com/Runscope/python-trigger-sample/master/app.py

Triggering Runscope During A Build

To run the Runscope script and execute your tests during your build, you can use the Runscope script you installed in your setup commands by calling the script in your project’s test or deployment commands.

Inside of your test or deployment commands, simply add the following:

python app.py https://api.runscope.com/radar/your_test_trigger_id/trigger?runscope_environment=your_runscope_environment_id

Note that you will need to change the URL to reflect the actual Trigger URL you have configured in Runscope.