What Is Integration Testing?
Integration testing verifies that separate components work correctly together, rather than testing each piece in isolation.
Code can pass every unit test and still fail when the pieces are connected, because the bugs live in the seams between them. Integration testing targets exactly those seams, the interactions between modules, services, and external systems.
What it is
An integration test exercises two or more components working together: your code talking to a database, two services exchanging messages, an API calling a third-party system. The goal is to confirm that the contracts and assumptions between components actually hold when wired up.
How it differs from unit tests
A unit test isolates one function, often replacing its collaborators with fakes. An integration test deliberately keeps the real collaborators connected, which makes it more realistic but slower and more involved to set up. Unit tests find logic bugs; integration tests find interface and wiring bugs.
An example
A service saves an order to a database. A unit test might check the order-building logic with a fake database. An integration test runs against a real (test) database, confirming the SQL is valid, the schema matches, and the saved record reads back correctly, things the fake could never reveal.
How it fits CI
Integration tests usually need real dependencies, so CI often spins up databases or services as containers for the test run. Because they are slower than unit tests, they typically run after the unit tests pass, and may run on a subset of changes or on a schedule for the most expensive ones.
Why it catches real bugs
Many production incidents come from mismatched assumptions between components, a renamed field, an unexpected null, a changed API. Integration tests catch these before release precisely because they test the real interactions rather than mocked stand-ins.
Key takeaways
- Integration testing verifies that components work together.
- It keeps real collaborators connected, unlike unit tests.
- It catches interface and wiring bugs that unit tests miss.