REST API Automation Testing Tutorial 1 with Rest Assured – Live Example



Rest Assured
Rest Assured API is used to test the REST [Representational State Transfer] methods as such GET,POST,DELETE and UPDATE Methods. REST API Documentation can be referred using the link http://www.javadoc.io/doc/com.jayway.restassured/rest-assured/2.9.0.
In this tutorial we will discuss about the usage of GET Method.
Before Getting into this Example Please follow the links mentioned below for better understanding of Rest Services.
Rest API Basics
REST API – FACEBOOK & GOOGLE API EXAMPLES

Pre-requisites
Follow the Steps in the Link to download the sample REST Application and deploy on
a tomcat Server-> REST API Application Live Example
Implementing the Framework
All the below methods taken care as part of Framework
1. Method Response getServiceResponse(String serviceURL) added as part of the RestLibrary.java class which helps to provide the response based on the end point URL passed as a parameter.


2. Methods used to store the Run time Value in setSysProperty() and fetch the value using getSysProperty().

3. This framework is implemented with Object Properties where the REST Endpoint url’s are
stored in the configuration.properties
.

3. Test case to retrieve all the Customers.


4. Test case to retrieve a particular customer by updating the Customer ID during run time.


5. Test case to retrieve a particular customer by updating the Customer ID using setProperty() and getProperty() Methods.

6. This framework is integrated with Allure as well, so the response can be viewed in the report itself.

REST API Live Example - GET Method Implementation

REST API Live Example – GET Method Implementation




Logic as follows:
RestAssuredExamples.java

RestLibrary.java

APIBaseClass.java

configuration.properties

Attaching the XML Response in Allure Report
1. Refer to complete implementation of Allure Reporting.

Allure Reporting





2. Add the below code in your Base Class.

Attaching the JSON Response in Allure Report
1. Refer to complete implementation of Allure Reporting.

Allure Reporting





2. Add the below code in your Base Class.

Leave a Reply

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