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 component 1 with component 2 (using a stub instead of component 3) comes down to checking two main scenarios:

  1. the cookie passes the quality check and should be added to Storage,
    Browser should receive the response with status OK
  2. the cookie fails the quality check and should not be added to Storage,
    Browser should receive the response with status 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
1xx Informational 102 — request is being processed (Processing)
2xx Successful 200 — request completed successfully (OK)
3xx Redirection 301 — resource has been moved (Moved Permanently)
4xx Client Error 400 — client request contains an error (Bad Request)
403 — client is not allowed to access this resource (Forbidden)
5xx Server Error 500 — server error occurred while processing the request (Internal Server Error)
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.

Take the role of the client and check if the components work together successfully.

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