Using ResponseSpecBuilder of Rest Assured ( Code Reuse )

In the previous post, we learned about Using RequestSpecBuilder of Rest Assured . In this post, we will learn about using ResponseSpecBuilder of Rest Assured. You can use the builder to construct a response specification. ResponseSpecBuilder is usually used when we have some common things to check across multiple tests. For e.g. the status code returned once the API is hit is 200, the contentType of the response returned is JSON, etc. Let's look at an example without ResponseSpecBuilder. Here we are making use of Google Search API that we studied in Testing GET Requests and their Responses using Rest Assured . import org.testng.annotations.BeforeClass ; import org.testng.annotations.Test ; import io.restassured.RestAssured ; import io.restassured.http.ContentType ; import static io. restassured . RestAssured .*; public class GetStatusCodeTest { @BeforeClass public void requestSpec () { RestAssured. baseURI = "https://maps.go...