Creating Simple REST Test Automation Framework

name-transparent

In this blog post, I will show how to quickly set up a testing automation framework for REST API testing, using JAVA.

TOOLS

I will use a few of my favourite tools for this simple framework:

Example of a simple REST test using Serenity/RestAssured/JUnit :

@RunWith(SerenityRunner.class)
public class SimpleRestFramework {

    private String url = "https://jsonplaceholder.typicode.com/posts/";

    @Test
    @Title("Simple Serenity RestAssured Test")
    public void simpleRestGetTest(){

        RestAssured.when().get(url)
                .then().statusCode(200);

    }
}

After you run this test case using JUnit, a report will be generated by serenity, the only thing that is left is to run this Maven command which will generate HTML 5 report summary (index.html):

mvn serenity:aggregate

This will generate a Serenity report which can be found in Target > Site > Serenity. This report contains a lot of useful information like request/response and steps that were executed.

Using this information you can start building a basic and simple REST automation framework with a great test runner and report building tool. This is basically all you need for REST testing using JAVA. Goodluck!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s