Request and Response Logging in Rest Assured Framework


Request and Response Logging in Rest Assured Framework


 Introduction

To print the response and/or request details in order to help us create the correct expectations and send the correct requests. RestAssured has provided us with Pre-defined filter. 

                               Request Logging

REST Assured supports logging the request specification before it's sent to the server using the RequestLoggingFilter.




For e.g, if we wanted to see complete response what is being sent to the server we can simply add log().all() in request header
  

Request Logging
  The Response in the output the console would be like

Request Output

Please Note the above output might be changed based on the parameter you sent with JSON request. In a similar way we can specify any other parameter in the log as per requirement.

Response Logging

In the Similar way as Request logging if we want to print the response body regardless of the status code we can do so by
then().log().body();

for logging the complete body request we can again use log().all() and the response would be like this.

Response Logging

Response Output




SHARE THIS

Author:

My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post