In this tutorial you are going to learn How to Automate the API Tests using RESTAssured Library
This project contains automated API tests explained step by step. The tech stack used for this project are:
- JAVA as the programming language for writing test code
- TestNg as the framework
- Gradle as the build tool
- IntelliJ as the preferred IDE for writing java code.
Setup your machine.
- Install JDK 1.8
- Install IntelliJ (Community edition is fine)
- Install Gradle
- Clone the project from
git clone https://github.com/vinaykumarvvs/api-automation-tutorial.git
- Import the project (API-automation-tutorial) in IntelliJ
File -> New -> Project from Existing Sources -> Browse Project Location -> build.gradle
- Now click on
auto import -> Ok
wait until the IntelliJ downloads all the dependencies
Note:
For 2nd & 3rd steps, you need to follow this way OpenTerminal/CMD -> cd <change-to-project-location>
- You can run the tests directly from the IntelliJ, by right-clicking and Run test.
- For Linux/Mac users:
gradle clean build runTests
- For Windows users:
gradlew clean build runTests
Throughout this tutorial, I am going to use PetStore-Swagger. PetStore - Swagger is the open source project which has very good documentation with the various number of examples.
- Test-1: Send a get Request of an API and validate the body
- Test-2: Send a get Request of an API by passing the Query Parameters in the URL itself
- Test-3: Send a get Request of an API and retrieve the data from the body
- Test-4: Send a get Request of an API and store the Response
- Test-1: Optimized way to send the Request and receive the Response
- Test-1: Creating the POST Request and validating the Response Code
- Test-1: Creating the POST Request and validating the RequestBody & ResponseBody
- Test-1 Creating a Pet using POST method and verifying it by using GET method