Integration Testing
What is it?
Integration testing checks that different parts of a system work correctly together, not just in isolation.
Explain like I'm 5
Why was it created?
Units can each pass their own tests yet fail when combined. Integration testing was adopted to catch problems at the seams between components.
Where is it used?
- Testing modules together
- Verifying database and API interactions
- Service-to-service checks
- CI pipelines
Why should developers care?
Many real bugs live in the interactions between parts, so integration tests catch issues unit tests miss.
How does it work?
You exercise multiple components together — for example, code plus a real database or a real API call — and assert the combined behavior is correct. They use more real dependencies and run slower than unit tests.
Real-world example
An integration test calls your API endpoint, which writes to a real test database, then checks the record was stored correctly.
Common use cases
- Catching interface mismatches
- Verifying database/API behavior
- Testing service interactions
- Confirming end-to-end paths within the system
Advantages
- Catches integration bugs
- Tests realistic behavior
- Verifies component contracts
- Higher confidence than units alone
Disadvantages
- Slower than unit tests
- More setup (databases, services)
- Harder to pinpoint failures
- Can be flaky
When should you use it?
When you need confidence that components work together, especially across boundaries like databases and APIs.
When should you avoid it?
As your only fast feedback loop — pair with quick unit tests for speed.
Alternatives
Related terms
Interview questions
Beginner
- What is integration testing?
- How does it differ from unit testing?
Intermediate
- Why are integration tests slower?
- What dependencies do they use?
Senior
- How do you keep integration tests fast and reliable?
- How do you balance unit and integration tests?
Common misconceptions
- "If unit tests pass, integration tests are unnecessary" — most bugs hide in how parts interact.
- "Integration tests should replace unit tests" — they complement each other; units are faster and more precise.
Fun facts
- The 'test pyramid' suggests many fast unit tests and fewer, slower integration and end-to-end tests.
- Integration tests often need real dependencies like a database.
Timeline
- 2000s — Integration testing formalized within automated test suites
Learning resources
Quick summary
Integration testing verifies that components work together across real boundaries like databases and APIs, catching bugs unit tests miss.
Cheat sheet
- Tests parts working together
- Uses more real dependencies
- Slower than unit tests
- Catches interface bugs