Junior — Middle
What methods or operations in REST Assured do you use most frequently in your work?
sobes.tech AI
Answer from AI
In working with REST Assured, I most often use the following methods:
given()— for setting up the request (headers, parameters, body).when()— for specifying the HTTP method and endpoint (e.g., GET, POST).then()— for verifying the response (status code, body, headers).
Example of usage:
import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
given()
.header("Content-Type", "application/json")
.body("{\"name\": \"John\"}")
.when()
.post("/users")
.then()
.statusCode(201)
.body("name", equalTo("John"));
I also frequently use methods for working with request parameters (queryParam), authentication (auth()), and logging (log().all()).