06-testing

Integration Testing

06-testing/integration-testing

Integration Testing

Overview

Integration tests verify that multiple parts of the system work together correctly.


Why It Matters

They catch bugs that unit tests miss, especially around data flow and boundaries.


Core Concepts

  • Test real interactions between components or services.
  • Focus on boundary behavior.
  • Keep the environment predictable.

Mental Models

Ask where the seams are: API, storage, auth, routing, or cross-component interaction.


Best Practices

  • Test the happy path and the failure path.
  • Keep dependencies realistic when possible.
  • Cover workflows that cross boundaries.

Common Mistakes

  • Recreating a full production stack for everything.
  • Testing too much internal detail.
  • Leaving integration suites slow or flaky.

Trade-offs

Integration tests are slower than unit tests, but they give more confidence that the system really works together.


Decision Framework

Use whenAvoid when
Boundary behavior mattersA unit test fully covers the behavior
A bug spans layersThe test would be too slow or fragile

Examples

  • Verify that form submission creates a record and updates the UI state.

Checklists

  • Did I cover the boundary behavior?
  • Is the setup realistic enough?
  • Is the test stable?

Senior Engineer Notes

Senior engineers use integration tests to protect the seams where regressions often appear.


Further Reading