---Advertisement---

API Testing Questions and Answers (Level-3)

By Manisha

Published On:

---Advertisement---

Question 5: Explain the complete flow of an API automation test using a tool like Rest Assured or Postman.

Answer:
A typical API automation test flow includes the following steps:

  1. Set Base URI
    Define the base address of the API:
    https://api.example.com
  2. Choose HTTP Method
    Decide which method (GET, POST, etc.) to use based on the test scenario.
  3. Add Headers
    Example: Content-Type: application/json, Authorization: Bearer <token>
  4. Add Request Body (for POST/PUT/PATCH)
    JSON body with relevant payload.

Send Request and Capture Response
Use code like this in Rest Assured:

java

given()

  .baseUri(“https://api.example.com”)

  .header(“Authorization”, “Bearer ” + token)

  .contentType(“application/json”)

  .body(jsonPayload)

.when()

  .post(“/users”)

.then()

  .statusCode(201)

  .body(“id”, notNullValue());

  1. Assertions
    Validate status codes, response body, headers, and time.
  2. Logging and Reporting
    Integrate with TestNG + Extent Reports or Postman’s Newman reports for CI/CD pipelines.

This structured approach ensures maintainability and scalability of your automation framework.

---Advertisement---

Leave a Comment