Sei sulla pagina 1di 11

API FRAMEWORK AND TOOLS

Using Rest Assured

Presented By- Prasad Hiwale


1
Agenda

 What is API Testing ?

 Why API Automation Required ?


 What is Rest Assured ?
 Why need of Rest Assured?
 Tools used in Rest Assured framework?
 Implementation process
 Report

2
What is API Testing ?

 An API is an Application Programming Interface.

 It enables communication and data exchange between two separate software


systems.

 API TESTING is a software testing type that validates Application Programming


Interfaces (APIs).

3
Why API Automation Required ?

 To check the functionality, reliability, performance, and security of the


programming interfaces.

 API test automation requires less code than GUI automated tests thus


providing faster test results and better test coverage

 Early Defect Detection

 Language Independent

 Time Effective

 Fast Result

 Reliable and Easily integration with GUI

4
What is Rest Assured framework ?

 REST - REST framework (Representational State Transfer) is an architectural


style, and an approach to communications that is often used in the
development of Web Services
 HTTP Methods:- GET, POST, PUT, DELETE

GET To read information.


POST To Create information
PUT To amend information.
DELETE To delete information

 REST Assured framework is a simple Java library for testing of REST services.
 Integrates seamlessly with existing Java based testing frameworks

• Junit, TestNG • Selenium Web-driver

5
Why need of Rest Assured framework ?

 Rest assured framework is a java-based tool used for automating Restful web


services. It is a powerful behavior driven library set up for testing out various API
endpoints and their response bodies. It helps in writing readable, maintainable
tests for RESTful APIs.

 It remove need of writing a lot of code required to set up an HTTP connection, send
a request and receive and parse a response

 It supports a Given/When/Then test notation, which instantly makes your tests


human readable

 Since REST Assured framework is a Java library, integrating it into a continuous


integration / continuous delivery setup is a breeze, especially when combined with
a Java testing framework such as JUnit or TestNG

 Easily be integrated with user Report like Extent report, Allure framework etc.

 It gives the method http and send it over network with validating status code 6
request with response correctly as compare to SOAP its light weight and secure.
Tools used in API Framework

 Java 1.8 more

 Rest Assured

 Eclipse

 MAVEN

 Test NG

 Allure Report
7
Implementation process…. Framework
 GETTING STARTED WITH REST ASSURED:-

Maven Dependency of REST Assured


<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.0.1</version>
<scope>test</scope>
</dependency>

 WRITING THE TEST

Rest Assured working on three principle

public void post Request() throws Exception {

given()
.body("{ \"id\": " + inputId + ", \"quantity\": 1}")
.header("Content-Type", "application/json")
.when().post(environment + "/store/order")
.then().assertThat().statusCode(200);

8
Response codes framework used…
REST API must always return an appropriate status code to the client so that the client can know the actual issue and process accordingly.
Below mentioned are the standard status codes, used in HTTP responses.

200 OK

201 Created

204 No Content

304 Not Modified

400 Bad Request

401 Unauthorized

403 Forbidden

404 Not Found


9
500 Internal Server Error
Reporting Tool - Allure
We are implementing allure report in our framework.

Advantage

 Easy to use.

 Open source.

 Light weight.

 Faster Executions.

 East to maintain – test data abstraction from test scripts

 High Reusability – keyword driven approach, same keywords can be used across project

 Unified Solution - supporting both Web Application and Mobile Application Automation

 Better collaboration – integration with JIRA, Jenkins, Bugzilla

@Annotations like using in report are @Title , @Description, @Step, Attachments, @Epic, @Feature,
10
@Story, @step and @Severity.
Thank You…

11

Potrebbero piacerti anche