Which method is used to validate the status code of a response in RestAssured?

Which method is used to validate the status code of a response in RestAssured?

A) statusCode()
B) checkStatus()
C) verifyStatus()
D) assertStatus()

Answer:

A) statusCode()

Explanation:

The statusCode() method in RestAssured is used to validate the status code of an HTTP response. It allows you to assert that the response status code matches the expected value.

For example:


import static io.restassured.RestAssured.*;

given().
    when().
    get("/api/resource").
    then().
    statusCode(200);

In this example, the statusCode() method asserts that the response status code is 200.

Reference links:

https://www.javaguides.net/p/top-java-libraries.html

Leave a Comment

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

Scroll to Top