Integration Testing
Integration testing checks whether connected components exchange data and behave correctly across their actual boundaries.
Download Markdown (.md)Soroush’s Product Wiki · https://wiki.soroush.uk/topic/integration-testing/
01What 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.[1][2]
02Why 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.
03When 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.
04How it works
- Identify a boundary and the interaction risks to verify.
- Create representative dependency versions, configuration, and test data.
- Exercise successful exchanges and important failure or timeout behavior.
- Assert externally visible effects, including persisted data where relevant.
- Clean up isolated fixtures and run the checks in the delivery pipeline.
05A 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.
06Where 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.
07Sources
- Integration TestMartin Fowler · Practitioner guidanceIntegration Test
- Integration tests in ASP.NET CoreMicrosoft · Official documentationIntegration tests in ASP.NET Core