agile3
Engineering Practices

Integration Testing

Testing how parts of a system work together: modules, services, databases and external APIs.

2 min read · Practitioner

In 30 seconds

  • Checks the connections between components.
  • Sits between unit tests and end-to-end tests.
  • Catches mismatched assumptions that unit tests miss.

What it covers

  • Code talking to a real database
  • One service calling another
  • Calls to external APIs
  • Message queues and file systems

Where it fits

Integration tests sit in the middle of the test pyramid: more than end-to-end tests, fewer than unit tests. They're slower than unit tests but catch problems at boundaries. See automated testing.

Contract tests

For microservices, contract tests check that a provider still meets what each consumer expects, without running the whole system. They catch breaking API changes early.

Myth vs reality

Myth · Integration tests are the same as E2E tests.
Reality · They test connections, not full user journeys.
Myth · Mocks make integration tests unnecessary.
Reality · Mocks hide real integration problems.
Myth · They must use production systems.
Reality · Test instances or containers work well.

FAQ

Should integration tests run in CI?

Yes, at least the fast ones on every change.

How do we handle external APIs?

Use sandboxes, test doubles or contract tests.

How many integration tests?

Enough to cover each important boundary.