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.