Testing APIs with REST-Assured

Rahul
2 min readDec 10, 2018

--

In a typical modern web application it is common to have web services which expose your backend functionality via API endpoints and you might want to test these endpoints. In this article I will focus on Rest-Assured, it provides us clean and simple API is so that we can use them to automate the rest services and we can use our Java language, so basically rest assured is also an API.

REST API Testing in Action

https://developers.google.com/maps/documentation/distance-matrix/intro

I would be automating GET request for Google Maps API. Please refer to above API doc for more details. If you put the below URL in browser or POSTMAN: https://maps.googleapis.com/maps/api/distancematrix/json?origins=Boston,MA&destinations=Lexington,MA&key=<Your API Key> then you will see response like this.

Please create your Google API key for above request.

Now we will try to get the same response via rest assured: I have put my code on Github and you can access it from the link at the bottom.

When you run the above test case as TestNG Test then also you will get the following response:

SUMMARY:

This was just a overview of Rest Assured and you can do a lot more with it. If you are planning to automate your testing of REST API and your choice of language is Java you should definitely try out this.

--

--

No responses yet