Make Selenium Easy

REST Assured Tutorial 53 – How to create ResponseSpecification using ResponseSpecBuilder


As a part of End to End REST Assured Tutorial, in this post, we will learn to create a ResponseSpecification using ResponseSpecBuilder class in Rest Assured.


I have used below dependency of Rest Assured library for this post:-

You should go through below posts once to understand this post better:-

Interface RequestSpecification – How The Request Will Look Like

ResponseSpecification – Specify How The Expected Response Must Look Like

What is ResponseSpecBuilder?

ResponseSpecBuilder class provides you a builder to create a ResponseSpecification. This class has self explanatory methods like expectStatusCode(), expectHeaders() etc compare to methods of ResponseSpecification interface.

We can create a ResponseSpecification using ResponseSpecBuilder as below:-

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

Example Program

You can download/clone the above sample project from here.

You can subscribe to my YouTube channel RetargetCommon to learn from video tutorials.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.

Find all Selenium related posts here, all API manual and automation related posts here, and find frequently asked Java Programs here.

Many other topics you can navigate through the menu.

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Leave a Reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.

REST Assured Tutorial 53 – How to create ResponseSpecification using ResponseSpecBuilder

by Amod Mahajan time to read: 2 min
%d bloggers like this: