This is a full-fledged tutorial on Rest API Automation testing using one of a very popular Java-based API i.e ‘Rest Assured‘ library. It is in high demand among automation testers. In this guide, we are going to present solutions that are easily understandable and quick to implement and use. This rest assured tutorial is not only for beginners but for advanced users as well.

Rest_Asssured_Tutorial_Rest_API_Testing_Techndeck

Rest Assured is a Java-based library.  It is one of the most popular libraries to test RESTful Web Services and used to perform testing and validation of Rest Services with simplicity. It can be considered as a wrapper implementation of the HTTP client library as it underneath performs the same operations as what HTTP client API does. RestAssured API is highly scalable and customizable and can be really effective to create extensive Requests to tests a particular service.

REST Assured Tutorial for REST API testing for beginners as well as advanced users...!!! Share on X

Check out: KARATE DSL (API Testing) TUTORIAL with examples

It provides a BDD-like structure to write the code that is one of the advantages of using it as it makes it simple to use.

BDD_Techndeck

As I’ve mentioned above that it is an implementation over the HTTP Client library, therefore, it would be simple to write the code in the REST-ASSURED as it is more refined and high level.

As it is a Java-based library, so it would be very easy to integrate with the UI test code in the automation testing framework.

Also, in this particular guide, we are going to use JSONPath for JSON manipulation and Hamcrest API for assertions.

REST Assured Tutorial for REST API testing for beginners as well as advanced users...!!! Share on X

Let’s have a look at REST-assured Syntax:

/Users/d33p4k/Downloads/RestAssured_Syntax_Techndeck.png

Let’s give you a brief idea here about how the above-mentioned code operates:

a. As per the above example, there is no method been passed to given. It means there are no specific preconditions there.

b. There is a ‘get’ method which is being passed to ‘when‘ and it signifies that when we are hitting this URL present in the ‘get’ method, an event occurs. 

c. When we hit the URL in ‘when’, ‘then‘ we are going to receive output as a response, and then we perform validation on it. Here in this particular example shown in the above image, we are performing an assertion on the body by validating the size of a specified element.

Let’s jump on the thorough REST Assured tutorial for beginners/advanced users, here we are going to cover the below topics:

REST Assured Tutorial for REST API testing for beginners as well as advanced users...!!! Share on X

Other Useful References:

Author

  • Deepak Verma

    Deepak Verma is a Test Automation Consultant and Software development Engineer for more than 10 years. His mission is to help you become an In-demand full stack automation tester. He is also the founder of Techndeck, a blog and online coaching platform dedicated to helping you succeed with all the automation basics to advanced testing automation tricks.

    http://Techndeck.com deepak.rkgit@gmail.com Verma Deepak