5🔗 Integration Test

Testing Strategies

  • Verify status code

  • Verify response body schema

  • Verify response headers

  • Verify response time

We will use the Restful Booker APIarrow-up-right for the following examples.


Rest-Assured (Java)

Rest-Assured is a Java DSL for simplifying testing of REST based services.

1. Dependency (pom.xml)

<dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>5.3.0</version>
    <scope>test</scope>
</dependency>

2. Example: Get Booking IDs

Scenario: Verify that we can retrieve booking IDs and the status code is 200.

3. Example: Create Booking (POST)

Scenario: Create a new booking and verify the response contains the booking ID.


Axios (JavaScript/Node.js)

Axios is a promise-based HTTP client for the browser and Node.js.

1. Installation

2. Example: Get Booking IDs

Scenario: Verify status code 200 and array length.

3. Example: Create Booking (POST)

Scenario: Create a booking and verify the response.

Last updated