REST Assured Tutorial 1 – Introduction to REST Assured


As a part of End to End REST Assured Tutorial, in this post, we will see the introduction of Rest Assured.

Demand for API Testing is increasing day by day as it helps in finding bugs early in the Software development life cycle and prevents major bugs at later stages. We can perform API Testing manually and programmatically i.e. Automation.

We have covered Manual API Testing using Postman. Now it’s time to learn about API Testing Automation using a Java library called Rest Assured.

What is Rest Assured?

REST-assured is an Open Source Java library that is used to test and validate REST APIs. Dynamic languages like Groovy, Ruby are helpful and simple to perform API testing which was harder in Java. Rest Assured is responsible to bring simplicity to do API Testing using Ruby and Groovy in Java.

REST Assured is a Java DSL for simplifying testing of REST-based services built on top of HTTP Builder. REST Assured supports any HTTP method but has explicit support for POST, GETPUTDELETEOPTIONSPATCH and  HEAD and includes specifying and validating e.g. parameters, headers, cookies and body easily. It can be used to validate and verify the response of these requests.

RestAssured is built on top of Apache HTTP Client. Sometimes it is asked why not to use HTTP client directly. The below screenshot should answer this question.

REST Assured is developed and maintained by Johan Haleby. He started the project when he was working at Jayway back in December of 2010. The project is now sponsored by Parkster.

Versions of Rest Assured

Rest Assured has a legacy version as well and many beginners start using that in confusion. When you search Rest Assured dependency in Maven Central Repo then you will find two different group ids.

com.jayway.restassured – This group is legacy. – This group is the latest.

You should start learning from group id ““.

Advantages of Rest Assured

  1. It is an Open source i.e. free.
  2. It requires less coding compare to Apache Http Client.
  3. The initial setup is easy and straightforward before you hit any endpoint.
  4. Easy parsing and validation of response in JSON and XML.
  5. The extraction of values and asserting is quite easy using inbuilt Hemcrest Matchers.
  6. It follows BDD keywords like given(), when(), then() which makes code readable and supports clean coding. This feature is available from version 2.0.
  7. Rich in syntax.
  8. Very rich in readymade assertions
  9. Quick assertion for status code and response time.
  10. Headers, cookies, Content-Type, etc can be verified on the fly.
  11. Powerful logging mechanism.
  12. Can be easily integrated with other Java libraries like TestNG, Junit as Test Framework and Extent Report, Allure Report for reporting purpose.
  13. Very good support for different authentication mechanisms for APIs.
  14. Can be integrated with Selenium-Java to achieve End to End automation.
  15. Supports JsonPath and XmlPath which helps in parsing JSON and XML response. Rest Assured by default integrates both.
  16. Can be used to verify JSON Schema using JSON Schema Validation library.
  17. Includes XML schema validation
  18. Can be integrated with Maven and CICD.
  19. REST Assured 4.1.2 is released. It adds support for Java 13.
  20. Supports multi-part form data
  21. Supports Spring Mock Mvc, Spring Web Test Client, Scala and Kotlin.

Disadvantages of Rest assured

  1. Does not support testing of SOAP APIs explicitly.
  2. Requires good Java programming knowledge
  3. No inbuilt reporting. Serenity BDD is a good option here.

YouTube Video

I have started a YouTube channel as well and you can find related Rest Assured video link here:-

Introduction To Rest Assured – English

Introduction To Rest Assured – Hindi

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.

Next Post

Setup A Basic REST Assured Maven Project In Eclipse IDE

7 thoughts on “REST Assured Tutorial 1 – Introduction to REST Assured

Leave a Reply

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