Integration Testing

Components integration with code 200

The goal of integration testing is to check how system components work together. It is done at a higher level than unit testing, where individual parts are already tested separately.

Integration testing can involve two or more components.

Integration Testing Example

As an example, let’s take a system made of three components:

Browser — a browser app for adding cookies

Storage — a service that stores cookie information

Quality Service — a service that checks cookie quality

Component Interaction Scenario

  1. Browser sends a request to add a new cookie to Storage
  2. Storage sends a request to Quality Service, to check if the cookie meets the quality requirements
Three web components
  1. Quality Service returns a response to the storage Approved, or Rejected depending on the result
  2. if the quality service returned Approved, the storage saves the cookie and responds to the browser OK
    if the quality service returned Rejected, the storage does not save the cookie and responds to the browser Bad Request

Using Stubs

It turned out that the component Quality Service is not ready yet, so to test the interaction between Browser and Storage we use a stub.

Stubs can be written by developers or testers.

Stub simulates the work of Quality Service and returns two possible responses:

  • round cookies Approved
  • not round cookies Rejected
Three components with one mocked

Running the Test

Integration testing of the interaction between the browser and the storage, where a stub is used instead of the quality service, comes down to checking two main scenarios:

Positive scenario

The cookie passed quality control and was added to the storage
Expected behavior: the storage returns OK

Negative scenario

The cookie failed quality control and was not added to the storage
Expected behavior: the storage returns Bad Request

HTTP Response Codes

In the positive scenario, when two components integrate successfully, we expect the server to return an HTTP response with code 200 OK to the client’s request. But there are also other response codes shown in the table.

Code Description Example Comment
1xx Informational 102 Processing The request is being processed
2xx Success 200 OK The request was completed successfully
3xx Redirection 301 Moved Permanently The resource has been moved to a different address
4xx Client Error 400 Bad Request
403 Forbidden
The client’s request contains an error
The client does not have permission to access this resource
5xx Server Error 500 Internal Server Error An error occurred on the server while processing the request
Task

The system under test consists of two components: client and server.

The frontend developer created the client part — “Form for sending an HTTP request”, and the backend developer wrote the logic on the server. They agreed on the rules for successful data exchange and aligned the API.

Perform integration testing of the client–server interaction.

Form for Sending an HTTP Request

Request format agreement:

  • Endpoint /hello-server
  • HTTP method, used to get data from the server

Expected response in case of successful integration:

  • Response status with code 200
  • Response body empty
On which side did the error occur?
Sidebar arrow