Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

How do you initiate request specification in REST Assured?

Category: Rest Assured

A RequestSpecification with some specifications can be created as below:-

RequestSpecification requestSpecification = RestAssured.given();
requestSpecification.baseUri(“https://hireqa.co.in”)
requestSpecification.basePath(“/register”);

Or instead of calling RequestSpecification reference multiple times, we can use the builder pattern as below:-

RequestSpecification requestSpecification = RestAssured.given()
.baseUri(“https://restful-booker.herokuapp.com”)
.basePath(“/booking”);

We can add a RequestSpecification to a request in multiple ways as shown below:-

RestAssured.given(requestSpecification)
OR
RestAssured.given().spec(requestSpecification)

Leave a Reply

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