What is Rest Assured?
Rest Assured enables you to test REST APIs using java libraries and integrates well with Maven. It has very efficient matching techniques, so asserting your expected results is also pretty straight forward. Rest Assured has methods to fetch data from almost every part of the request and response no matter how complex the JSON structures are.
For the testing community, API Automation Testing is still new and niche. The JSON complexities keep API testing unexplored. But that does not make it less important in the testing process. Rest Assured.io framework has made it very simple using core java basics, making it a very desirable thing to learn.
Why need Rest-Assured?
Imagine you open your google map view and look for a place you want to go, you immediately see close by restaurants, you see options for the commute; from some leading travel providers, and see so many options at your fingertips. We all know they are not google products, then how does Google manage to show it. They use the exposed APIs of these providers. Now, if you are asked to test this kind of setup, even before the UI is built or is under development, testing APIs becomes extremely important and testing them repeatedly, with different data combinations makes it a very suitable case for automation.
Earlier, we were using dynamic languages such as groovy, ruby to achieve this, and it was challenging. Hence API testing was not explored by functional testing.
But using Rest Assured, automation testing of APIs, sending simple https requests with user-friendly customizations is simple if one has a basic background of java. It is needed to understand API testing, and integration testing, but post that automation Rest Assured gives very good confidence on the backend while front-end testing can just focus on the UI and client-side operations. Rest Assured is a open source with a lot of additional methods and libraries being added has made it a great choice for API automation.
Use the following dependency in your Maven Projects – pom.xml
JSON Simple
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
Rest Assured
<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>5.3.0</version>
<scope>test</scope>
</dependency>