TechPro
Office address BhauAutomation VTP Cygnus Pune bhauautomationlab@gmail.com

Welcome to BhauAutomation!

What is REST Assured?

REST Assured is a Java library used to automate API testing. It helps us send requests to an API and check whether the response is correct.

For example, when a user opens a website, the application may request user details from an API. REST Assured helps us test whether the API returns the expected information.

Why Use REST Assured?

  • Automates API testing using Java.
  • Supports GET, POST, PUT, and DELETE requests.
  • Checks response status codes and JSON data.
  • Makes API test scripts easy to read.
  • Helps reduce manual testing work.

Simple Java Example

Imagine we want to check whether an API returns a successful response.

First, add the REST Assured dependency to your Maven pom.xml file.

Then create a Java test:

import static io.restassured.RestAssured.*;
import org.testng.annotations.Test;

public class ApiTest {

    @Test
    public void checkApiResponse() {

        given()
        .when()
            .get("https://jsonplaceholder.typicode.com/posts/1")
        .then()
            .statusCode(200);

        System.out.println("API Test Passed!");
    }
}

Expected Output:

API Test Passed!

Simple Explanation

  • given() – Sets up the request.
  • when() – Sends the GET request.
  • then() – Checks the response.
  • statusCode(200) – Verifies that the API returned a successful response.

Conclusion

REST Assured makes API automation easy for Java testers. Start with GET requests and status-code checks, then learn POST, PUT, DELETE, and JSON response validation.

Keep Learning with BhauAutomation!

Share:

Leave a Reply

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