Modules
Intermediate⏱ 7 min read

Integration Testing

sign in to track

ntegration testing is the process of testing whether two or more modules, components, or services work correctly when they are combined.

While unit testing checks individual components in isolation, integration testing focuses on how those components communicate and work together. It helps identify problems with interfaces, data transfer, API communication, database interactions, and dependencies between different parts of the system.

A component may work correctly on its own but still fail when it interacts with another component. Integration testing helps identify these types of problems.

Example

Consider an e-commerce application with these components:

Product Service → Order Service → Payment Service → Database

A unit test may verify that the Order Service correctly calculates an order total.

An integration test can verify that:

  1. The user selects a product.

  2. The Order Service receives the product information.

  3. The Order Service communicates correctly with the Product Service.

  4. The order information is saved to the database.

  5. The Payment Service receives the correct order amount.

  6. The payment result is returned correctly to the Order Service.

The focus is not just on whether each component works individually, but whether the components work correctly together.

What Does Integration Testing Check?

Integration testing commonly verifies:

  • Communication between modules or services.

  • Data passed between components.

  • API requests and responses.

  • Database interactions.

  • Service-to-service communication.

  • Interfaces between different systems.

  • Handling of errors between dependent components.

  • Correct processing of data across multiple components.

Why Integration Testing Is Important

Integration testing helps identify problems that may not be detected during unit testing, such as:

  • Incorrect data passed between components.

  • API contract mismatches.

  • Incorrect request or response formats.

  • Database integration problems.

  • Authentication or authorization issues between services.

  • Incorrect handling of errors or failures from dependent services.

  • Communication problems between different systems.

Unit Testing vs Integration Testing

Unit Testing

  • Tests a small component in isolation.

  • Focuses on the internal behavior of that component.

  • Usually executes very quickly.

  • Helps identify problems within individual units.

Integration Testing

  • Tests multiple components together.

  • Focuses on communication and interaction between components.

  • Usually involves more dependencies than unit testing.

  • Helps identify problems at system boundaries and interfaces.

◈Key Points

  • Approaches: Big Bang (all at once), Top-Down, Bottom-Up, and Sandwich/Hybrid.
  • Common integration failures: wrong API contract, data format mismatch, authentication handshake errors.
  • Use real (or realistic) databases and services where possible — in-memory stubs hide real issues.
  • Integration tests are slower than unit tests but faster than E2E — they live in the middle of the pyramid.
  • In microservice architectures, contract testing (Pact) is a powerful form of integration testing.
⚡ Expert Pro Tip

Define and publish API contracts between teams before integration testing begins. Contract-first development eliminates the most expensive integration failures.