rest assured api testing code example
Example 1: rest assured
RestAssured: is a library for testing restful API programmatically.
it use a library called Hamcrest for aserting the response
import static io.restassured.RestAssured.* ;
Example 2: how to define api details in rest assured automation
We should define all request details
and send it to server in Given,When,Then
methods
Example 3: rest assured script
The syntax of Rest Assured.io is the most beautiful part, as it is very
BDD like and understandable.
Given(). (lets you set a background)
param("customer_id", "102").
header("z", "w").
when(). (marks the premise of your scenario. For ex: get url)
Method(). (replace it with any of CRUD operations like get post put delete)
Then(). (your assert and matcher conditions goes here)
statusCode(xxx).
Body("x, "y", equalTo("z"));