# Integration Testing

Integration testing checks whether connected components exchange data and behave correctly across their actual boundaries.

- Type: practice
- Domain: Engineering & architecture
- Level: Intermediate
- Last reviewed: 2026-10-19
- Original: [Soroush’s Product Wiki](<https://wiki.soroush.uk/topic/integration-testing/>)

## What it means

Integration testing exercises interactions among software components or between a component and infrastructure such as a database. Its boundary may be narrow, covering one adapter, or broad, covering several services. The defining concern is collaboration: individually correct components can still disagree about formats, configuration, timing, and failure behavior.

## Why it matters

Boundary defects can break customer tasks despite a passing unit suite. Testing real interactions exposes incompatible schemas, serialization errors, transaction behavior, and configuration assumptions before deployment.

## When to use it

Use it when changing persistence, adapters, service contracts, or wiring. Keep the tested boundary explicit and use controlled environments. If all collaborators are mocked, the test cannot demonstrate compatibility with the real dependency it claims to cover.

## How it works

1. Identify a boundary and the interaction risks to verify.
2. Create representative dependency versions, configuration, and test data.
3. Exercise successful exchanges and important failure or timeout behavior.
4. Assert externally visible effects, including persisted data where relevant.
5. Clean up isolated fixtures and run the checks in the delivery pipeline.

## A practical example

A reservation service passes unit tests against a fake repository. An integration test against the supported database finds that a duplicate reference violates a constraint differently than expected. The team corrects error handling before customers encounter failed confirmations.

## Where it breaks

External dependencies increase setup cost and failure ambiguity. A local dependency may differ from production in permissions, versions, or scale. Broad suites can become slow, so choose interaction risks deliberately instead of rebuilding every end-to-end scenario.

## Common mistakes

- Calling a fully mocked dependency test proof of integration.
- Sharing a database fixture without reliable cleanup.
- Testing only successful responses while ignoring incompatibility and failure paths.

## Sources

1. [Integration Test](<https://martinfowler.com/bliki/IntegrationTest.html>) — Martin Fowler · Practitioner guidance
2. [Integration tests in ASP.NET Core](<https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests>) — Microsoft · Official documentation

## Related topics

- [Database Transaction](<https://wiki.soroush.uk/topic/database-transaction/>)
- [API Versioning](<https://wiki.soroush.uk/topic/api-versioning/>)
- [Continuous Integration](<https://wiki.soroush.uk/topic/continuous-integration/>)
