REST Assured: A beginner’s guide for REST API testing.

Reading Time: 3 minutes

Brief Idea about Functional Testing:-

Functional testing is basically the testing of component or application under test. In functional testing, we tend to cover all the actions and scenarios which user of the system can perform. In this approach, we focus mainly on two perspectives 1. Requirement based testing, 2.Business process-based testing. When it comes to the functional testing of API or web services then it becomes some different skill set and tools. For addressing this relatively new domain there are many tools and frameworks available in the market some of them are paid and some of them are open source and free to use.

What is REST Assured?

REST Assured is simple java library which is used to test REST services and create an automated script. It can be used for regression testing of REST services or one can use it for smoke testing, sanity testing depends on requirement. REST Assured is developed by JayWay company. This library can be used along with JUnit or TestNG testing framework to enhance test case maintainability and reporting.

Why REST Assured?

There are many reasons for choosing REST Assured for testing REST services. With all the below features one can handle automated REST API testing much easier.

  1. It provides simplicity like dynamic languages such as Ruby and Groovy.
  2. REST Assured working as the black box while testing one’s application.
  3. It supports all classic test runners such as JUnit or TestNG.
  4. We can write tests for the application written in any language such as Python,Ruby,Java,.Net ETC.
  5. Rest Assured is free to use and there is no explicit license required to use.
  6. It supports scala and groovy thus it can be used by various developer/QA who knows these various languages.
  7. Rest Assured can be used as Maven dependency.
  8. It supports POST, GET, PUT, DELETE, OPTIONS, and HEAD.
  9. It provides DSL-Like syntax.
  10. If someone needs to perform JSON Schema validation than it supports these and this is one of the cool features and provides basic validation.
  11. It provides Specification Reuse.
  12. Rest assured also provides easy file upload so one need not worry about this action and don’t need to write complex java code anymore.

Who should use REST Assured:-

REST Assured provides gherkin type syntax, individual(QA professional) will love if he is a BDD(Behaviour Driven Development) lover. As REST Assured is free to use and is based on Java, so it becomes the perfect candidate for used as REST API testing. As it is based on Java so one can get help from the huge Java community. 

How to make POST Request with REST Assured:-

  1. Rest API URL:- URL of the Rest API Endpoint.
  2. API Body:- Request Body of the REST API Endpoint.
  3. Headers:- Pass the required Headers for requested Endpoint URL. Content-Type = application/json. Ex. setContentType() method.
  4. Authentication credentials;- Pass the username and password to the basic() method, leave basic() blank if there is no authentication. Ex. basic(“”,””)


  1. Add the following dependencies in pom.xml:-

2. Now create a java class and then annotate the test method with @Test annotation than use following basic syntax structure to make GET request:-

Conclusion:- As we know  API/Web Services are gaining popularity in the current development scenario. There are many free and paid tools available for API testing but when it comes to the flexibility and rich support of the various readily available feature then RestAssured is surely a good choice. It has all the useful library and feature which enhances the API functional testing.




Written by 

QA Consultant