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.* ;
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.* ;
what is rest assured library
A non-web service API that's BDD format and helps
integrate java code using deserialization and
serialization to extract data from the Json and
transform it into a java object in order to store,
verify, and validate the data to the expected one.
why need rest assured
Imagine you open your google map view and look for a place you want to go,
you immediately see closeby 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 but google manage to
show it. They use the exposed APIs of these providers.
Even before the UI built or under development, API testing becomes very
important, we are testing them repeadetly with different data combinations
makes it a very suitable case for automation.
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"));
API/Webservices with RestAssured Library?
import static io.restassured.RestAssured.* ;
URI uri = new URI(" ... / methods(get, post)”)
GET;
Response response =
given().accept(ContentType.JSON).
when().get(URI);
response.
then().assertThat().statusCode(200).
and().assertThat().ContentType(ContentType.JSON);
POST;
Response response =
given().ContentType(ContentType.JSON).with().
accept(ContentType.JSON).and().body(JSONbody).
when().post(URI);
response.
then().assertThat().statusCode(200);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us