Course contentsShow
← Software Engineering
Lesson 526 of 1,93316. Integration TestingFree lesson

Narrow Integration Tests

Focusing integration tests on small groups of collaborating components to isolate boundary failures quickly.

Narrow Integration Tests

What you'll learn: How to keep integration tests focused on small groups of collaborating components so you can quickly identify where boundary failures occur.


The Core Idea

When multiple components work together, you need integration tests to verify their communication. But testing every component in your system at once creates slow, brittle tests that are hard to debug. Narrow integration tests focus on small clusters of collaborating components—typically two or three—while using test doubles for everything else.

Think of it like debugging holiday lights. If you test the entire string at once and it fails, you can't tell which bulb is broken. Instead, you test small sections one at a time to isolate the problem quickly.

Why Keep Integration Tests Narrow

When an integration test fails across many components, you face a detective mystery: which component is broken? Which boundary caused the failure? Narrow tests eliminate this guessing game.

For example, imagine testing how your OrderService communicates with a PaymentAdapter that wraps an external payment API. A narrow integration test would:

  • Use the real OrderService and PaymentAdapter
  • Use a test double for the actual external payment API
  • Verify that OrderService correctly calls PaymentAdapter methods with proper data
  • Verify that PaymentAdapter correctly transforms responses back to OrderService

You're testing just the boundary between these two components, not the entire system from UI to database.

Benefits

  • Fast failure isolation: You immediately know which boundary broke
  • Faster execution: Fewer real components means less setup overhead
  • Easier debugging: Small scope means fewer variables to investigate
  • Better signal: Failures point directly to integration problems, not unrelated issues

Key Takeaway: Narrow integration tests verify small groups of collaborating components in isolation, giving you quick, precise feedback about boundary failures without the complexity of full system tests.