Testing with rest-assured in 10 minutes

Which tools are we going to use here?

Let’s start

Testing APIs with Rest-assured

Directory and files

Basic thoughts

List of endpoint responses

Create your test class

Imports and first class code

List of endpoints

List of existent endpoints

Defining URL

Endpoint address

If only the status matter

Status and latency testing

Starting from the most straightforward endpoint

List of employee’s ID
Employee list schema
Simple schema generator in python
Resource folder
Comparing response with schema
Executing the test method
Test status green

Creating and deleting employees

Database employee schema
Test create employee endpoint
Employee created with only names set in the request. Response retrieved from: /employees/data/<id>
All values for creating employee
Checking the success message after deleting the last employee
Deleting employee with ID “TestFail” (String)
Trying to delete employee that doesn’t exists (-1 ID)

Schemas for everything

All schemas
Comparing schemas for deleting successfully
Employee data schema
Getting the ID number 1 employee in the list

Covering other cases

Employee without the last na
Different date format
Sending text instead of a number
Fail when trying to delete employee with invalid ID
Fail when trying to get employee’s data with invalid ID

One more thing, ordering tests

Ordering tests

Final notes

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store