Automate REST API testing with ROBOT framework

Robot Framework is language-agnostic open-source test automation framework for test automation and robotic process automation (RPA).
It is operating system and application independent. Several standard libraries are bundled with the framework, and there are separately developed external libraries galore that can be installed based on your needs. Libraries provide the actual automation and testing capabilities to framework by providing keywords. Test cases are written using a keyword-testing methodology written in a tabular format. You get more information about it here

Why ROBOT Framework ?

Might be thinking there are already quite a number of Rest API testing frameworks like Postman, SoapUI, JMeter, Rest-Assured and several others.
How is wrting test cases using Robot Framework different from others. Robot framework is language-agnostic, you need not learn any language or scripting for write test cases. ROBOT framework is not only for REST APIs testing, it can be used for testing GUI (using selenium library ), verify database (using database library) and there are many more libraries which can be leveraged.

Using RestInstance Library

Here we will see how to use RESTinstace library that is part of the Robot framework to test RESTful APIs. The Keywords provided in the library are simple to use, supports all the methods (GET, PUT, POST, PATCH, DELETE) , supports sending custom the headers, keywords for validating the reasponse header and also validates JSON using JSON Schema.

*** Settings ***
Library String
Library REST ssl_verify=false
Set expectations
Expect response { "status": { "enum": [200, 201, 204, 400] } }
Expect response { "seconds": { "maximum": 2} }
*** Test Cases ***Get Employee
GET employee/1001
Output response body
String response body employee 1001
{"employee": "1001"}

Running the Test cases

I have created Docker Image for Robot Framework and then installed RESTinstace library, so we can run tests isolated from the application.
This kind of setup will be helpful for running smoke and regression tests after deploying the application and without distrubing the application. You can find scripts to build Docker image here.

Test case to test REST API

In test case i am using to test REST API . Run the test case placed in tests folder using , it launches a docker, copies the test cases and executes them.

Test Execution Results

Robot Framework genrates nice test report for all the test-case executed with detailed steps and execution status.


Robot Framework can be used to write smoke and regression test cases and test the application in isolation and RestInstance is a powerful library in terms of JSON schema checking and validations. You can get more information about RESTInstance here

Java enthusiast and open source contributor

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store