Saturday, August 21, 2021

Post#135-API#4 Rest assured Introduction and set up

👇 

What is Rest assured?

Rest assured is java library for testing Restful Web services. It can be used to test XML & JSON based web services. It supports GET, POST, PUT, PATCH, DELETE, OPTIONS and HEAD requests and can be used to validate and verify the response of these requests. Also it can be integrated with testing frameworks like JUnit, TestNG etc.

Prerequisites: Java, IDE (Eclipse, IntelliJ, etc), Maven & TestNG

The benefits of REST Assured

There are three main aspects of REST Assured that make it a powerful library for API testing:

  1.     It removes the need for writing a lot of boilerplate code required to set up an HTTP connection, send a request and receive and parse a response
  2.     It supports a Given/When/Then test notation, which instantly makes your tests human readable
  3.     Since REST Assured 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.

Steps to configure Rest Assured

Step 1) Install Java. 

Step 2) Download an IDE (Eeclipse or Intellij)

Step 3) Configure TestNG & REST Assured

After creating your maven project add dependencies in pom.xml.

Maven dependency for rest assured
<dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>4.3.0</version>
    <scope>test</scope>
</dependency>

Maven dependency for testng
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>7.1.0</version>
    <scope>test</scope>
</dependency>


Now you are done with the setup for Rest Assured Library.

🙏



No comments:

Post a Comment