Understanding Restassured BDD Method- Given, When,Then
Given
Sets up the preconditions for the request — base URI, headers, query parameters, or request body.
When
Specifies the actual action to perform — the HTTP method and endpoint, such as .get("/users") or .post("/login").
Then
Defines the expected outcome — assertions on status code, headers, or response body content.
given().header("Content-Type", "application/json")
.when().post("/login")
.then().statusCode(200).body("token", notNullValue());
PreviousIntroducing BDD Concepts In Restassured
Next Passing Base Url, Headers, Body data, Method type & Endpoint Of API In Restassured
Ready to master real-world software testing?
Learn manual and automation testing hands-on with mentor-led sessions.
.png)