how to define api details in rest assured automation code example
Example 1: 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 2: 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);
Example 3: 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.