Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

Write a code that tests REST API using REST Assured.

Category: Rest Assured
import org.testng.annotations.Test;

import io.restassured.RestAssured;

import io.restassured.http.Method;

import io.restassured.response.Response;

import io.restassured.specification.RequestSpecification;

public class EmployeesTest {

    @Test

    public void GetAllEmoloyees()

    {

           // base URL to call

           RestAssured.baseURI = "http://localhost:8080/employees/get"; 

           //Provide HTTP method type - GET, and URL to get all employees

           //This will give respose

           Response employeesResponse = RestAssured.given().request(Method.GET, "/all"); 

           // Print the response in string format

    System.out.println(employeesResponse.getBody().asString());

 

    }

}

Leave a Reply

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