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

How do you log a request and response in case REST Assured fails a validation?

Category: Rest Assured

If the test validation fails, log().ifValidationFails() will log everything in a request and response.

@Test

public void testIfValidationFails() {

     given().

     baseUri("http://localhost:8080").

     header("X-REGION", "NAM").

     log().ifValidationFails().

     when().

     get("/employees").

     then().

     log().ifValidationFails().

     assertThat().

     statusCode(200);

}

Leave a Reply

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