Integration Testing Approaches
Contrast top-down, bottom-up, and hybrid integration strategies — ISTQB Foundation Level §4.2 & §4.3
Learning Objectives
Concept Overview
Integration testing verifies the interfaces and interactions between integrated components or systems. Where unit testing asks "does this function work?", integration testing asks "do these components work together correctly?"
ISTQB FL v4.0 §4.2: "Integration testing focuses on interactions between components or systems. Defects are often found in the interfaces, data passed between components, integration sequences, and third-party or legacy system interactions."
What Is Integration Testing?
Key Definitions
The shared boundary between two components where data, control, or events are exchanged (API calls, method parameters, shared files, message queues, databases).
The process of combining individually tested units into larger subsystems and eventually a complete system.
Testing to expose defects in the interfaces and interactions of integrated components or systems.
The plan specifying the order in which components are combined and tested — top-down, bottom-up, hybrid, or big-bang.
Why Integration Defects Are Hard to Find
Component Integration vs System Integration Testing
| Attribute | Component Integration Testing (CIT) | System Integration Testing (SIT) |
|---|---|---|
| Scope | Interactions between units/components within one subsystem | Interactions between entire subsystems or external systems |
| V-model level | Corresponds to component design | Corresponds to system architecture / HLD |
| Basis | Component interface specifications, class diagrams | System architecture, interface control documents, API contracts |
| Typical interfaces | Function calls, shared memory, object method calls | REST/SOAP APIs, message brokers (Kafka/RabbitMQ), databases, file systems |
| Environment | Developer workstation or CI pipeline; lightweight stubs/mocks | Integration or staging server; real (or emulated) external systems |
| Who tests? | Developer or SDET | QA engineer with system architecture knowledge |
| Typical defect types | Wrong parameter types, missing return values, incorrect object state after call | Authentication failures, serialisation errors, SLA violations, missing error handling across system boundaries |
Top-Down Integration Strategy
Definition: Begin with the highest-level (controlling) module and progressively integrate lower-level modules. Lower-level components that are not yet ready are replaced by stubs.
Direction: Root → leaves of the call hierarchy (breadth-first or depth-first).
Architecture Example — 3-Layer Web Application
Top-Down: Advantages vs Disadvantages
Stub Design Guidelines
A stub must faithfully simulate the interface contract of the real module it replaces. Stubs should:
- Accept the correct parameter types and validate inputs (don't silently accept wrong types).
- Return realistic data structures, not just
Noneor hardcoded empty objects. - Simulate different response scenarios (success, empty result, error) using configurable mode switches.
- Be documented and version-controlled alongside the tests that use them.
Bottom-Up Integration Strategy
Definition: Begin with the lowest-level (leaf) modules and progressively integrate higher-level modules. Higher-level components not yet available are replaced by drivers.
Direction: Leaves → root of the call hierarchy.
Architecture Example — Same 3-Layer Application
Bottom-Up: Advantages vs Disadvantages
Driver vs Stub — Side-by-Side
| Property | Stub (used in Top-Down) | Driver (used in Bottom-Up) |
|---|---|---|
| Replaces | A lower-level module not yet available | A higher-level module not yet available |
| Role | Called by the unit under test; returns canned data | Calls the unit under test; simulates the caller |
| Complexity | Higher — must faithfully simulate return values and state | Lower — just invokes the UUT with test inputs |
| Lifespan | Replaced as real lower-level modules are integrated | Replaced as real higher-level modules are integrated |
| Code example | Stub returns {"user": "Alice", "role": "admin"} instead of calling DB | Driver calls UserRepository.findById(42) and prints the result |
Hybrid (Sandwich) Integration Strategy
Definition: Combines top-down and bottom-up simultaneously. The system is divided into three tiers:
- Top tier — integrated top-down (UI/API controllers).
- Middle tier (target layer) — the integration meeting point, often the service/business logic layer.
- Bottom tier — integrated bottom-up (repositories, utilities, external adapters).
Hybrid Advantages
Hybrid Disadvantages
Big-Bang Integration
Definition: All components are integrated simultaneously in one step and the whole system is tested at once. No stubs or drivers are used; all units must be complete before integration begins.
When Big-Bang Is Justified
Big-Bang Risks (why it's usually rejected)
Integration Strategy Comparison
| Criterion | Top-Down | Bottom-Up | Hybrid | Big-Bang |
|---|---|---|---|---|
| Test doubles needed | Many stubs | Many drivers | Some stubs + some drivers | None |
| Early UI/control-flow test | Yes | No | Yes | No |
| Critical module tested early | No | Yes | Yes | No |
| Parallel development | Limited | Good | Best | None |
| Defect localisation | Good (one new module per step) | Good (one new module per step) | Good (coordinated steps) | Very poor |
| Stub/driver effort | High | Medium | Medium | None |
| Stakeholder demo capability | Early | Late | Early | Late |
| Scheduling complexity | Low | Low | High | Lowest (but risky) |
| Best suited for | UI-critical, monolithic systems | Algorithm-heavy, reusable-library systems | Large multi-team enterprise systems | Tiny systems; legacy retrofit |
| ISTQB recommendation | Acceptable | Acceptable | Preferred for large systems | Discouraged |
Strategy Selection Guide
Typical Defects Found in Integration Testing
| Defect Category | Description | Example | Detected by |
|---|---|---|---|
| Data format mismatch | Component A passes data in a format Component B does not expect | A sends date as Unix timestamp; B expects ISO 8601 string | Any integration strategy |
| Incorrect parameter passing | Wrong number of arguments, wrong order, or wrong data types across the interface | Function called with (amount, accountId) but signature expects (accountId, amount) | Any integration strategy |
| Missing error propagation | A lower-level exception is swallowed or incorrectly translated at a higher layer | DB constraint violation caught but not surfaced to the UI, returning HTTP 200 on failure | Top-down (after real module integrated) |
| State corruption | Component A leaves shared state in an inconsistent condition that corrupts B's subsequent operations | Session object mutated by auth module breaks the order processing module | Hybrid; any strategy with shared state |
| Timing / race condition | A concurrency defect in the interaction between two components | Inventory decrement and payment processing run in parallel; oversell occurs | System integration testing |
| Protocol mismatch | Components use incompatible communication protocols or versions | Service A expects OAuth 2.0 Bearer tokens; Service B sends Basic Auth | System integration testing |
| Missing integration logic | A required step in the interaction is omitted (e.g., commit, flush, close) | Transaction started but never committed; data silently discarded | Bottom-up / hybrid |
| Non-functional interface violations | Response time, throughput, or payload size exceeds agreed limits | Internal API returns 2 MB JSON payload where the consumer expects ≤ 100 KB | System integration testing with performance tools |
Worked Example: E-Commerce Order System
Given the following system architecture, select and justify an integration strategy, then derive the integration sequence.
System Architecture
Strategy Recommendation: Hybrid
Justification:
- The Payment Gateway Adapter interfaces with an external system (Stripe) — high technical risk → test bottom-up first.
- The UI/OrderController has business-critical workflow that stakeholders need to demo early → test top-down.
- The Service Layer is the natural "meeting point" where both directions converge.
- Multiple teams can work in parallel: frontend team tests top-down; backend team tests bottom-up.
Hybrid Integration Sequence
| Step | Direction | Components Added (Real) | Test Doubles Used | Objective |
|---|---|---|---|---|
| 1a | Bottom-up | OrderRepository, InventoryRepository | Drivers for OrderService, InventoryService | Verify DB read/write correctness |
| 1b | Bottom-up | PaymentGatewayAdapter | Driver for PaymentService; Stripe sandbox | Verify external API integration (tokenisation, charge, refund) |
| 2a | Top-down | OrderController | Stub for OrderService | Verify HTTP routing, request parsing, response formatting |
| 2b | Top-down | CartController, UserController | Stubs for respective services | Verify UI workflows end-to-end (with stubs) |
| 3 | Convergence | OrderService, InventoryService, PaymentService | None — stubs and drivers replaced | Full integration: real controllers + real services + real repositories |
| 4 | System | All subsystems including external (Stripe, DB) | None | End-to-end order placement, payment, inventory deduction |
Sample Integration Test (Python / pytest)
Modern Integration Testing Patterns
In modern CI/CD and microservice architectures, classical top-down/bottom-up strategies are supplemented by new approaches.
Every commit triggers the full unit + integration test suite automatically. Integration tests run in isolated Docker containers with real (but ephemeral) databases and queues. Defects are detected within minutes of introduction.
Each consumer service defines a "contract" of what it expects from a provider. The provider's CI pipeline verifies it meets all consumer contracts. Used in microservices as a lightweight alternative to full integration tests.
Tools like Postman/Newman, REST-assured, or Karate test REST/GraphQL APIs in isolation. Focuses on request/response schema, status codes, error handling, and authentication.
Advanced form of stubbing where a virtual service records real traffic and replays it, eliminating the need to manually write stubs. Tools: WireMock, Mountebank, Hoverfly.
Consumers define expected interactions; providers must satisfy all consumer contracts. Removes the need for a shared staging environment during integration.
Integration tests spin up real Docker containers (Postgres, Redis, Kafka) programmatically. Eliminates "works on my machine" problems; DB is fresh for each test run.
Integration Testing in CI/CD Pipeline
Common Mistakes in Integration Testing
Class Activity (20 min)
Activity: Integration Strategy Selection for a Hospital System
The hospital information system (HIS) has the following architecture. In groups of 3:
- Identify all component interfaces (label each interface I1, I2, …).
- Select an integration strategy and justify your choice (3 reasons minimum).
- Produce an integration sequence table (minimum 4 steps) with: components integrated, test doubles used, and objective of each step.
- Identify 3 typical defects you expect to find and at which integration step they would be detected.
System Architecture
Hints
- The InsuranceGateway calls an external NHS API — consider the risk of external dependency.
- PatientPortal must be shown to hospital management early in the project.
- The NotificationService sends real emails — it must be carefully isolated in testing.
Activity Rubric
| Criterion | Excellent (4) | Good (3) | Adequate (2) | Needs Work (1) |
|---|---|---|---|---|
| Interface Identification | All 7 interfaces correctly identified and labelled | 5–6 interfaces identified | 3–4 interfaces | Fewer than 3 |
| Strategy Selection & Justification | Correct strategy with 3+ well-reasoned justifications referencing risk, team, and timeline | Correct strategy, 2 justifications | Plausible strategy, weak justification | No clear justification |
| Integration Sequence | 4+ steps; correct stubs/drivers; logical progression; objectives stated | 4 steps; minor stub/driver errors | 2–3 steps; some confusion | Fewer than 2 steps |
| Defect Identification | 3 realistic defects mapped to correct integration steps | 2 defects with step mapping | 2 defects, weak mapping | Generic or missing defects |
Exit Ticket
- A system has a critical payment processing module at the bottom of the call hierarchy. Which integration strategy best ensures this module is tested first, and what test double is required?
- What is the key difference between a stub (used in top-down) and a driver (used in bottom-up)?
- Give two reasons why big-bang integration is discouraged for systems with more than 5 components.
- Name one advantage and one disadvantage of the hybrid integration strategy compared to pure top-down.
Model Answers
- Bottom-up integration — integration begins with the lowest-level modules (including the payment processor). A driver is required to call the payment module and provide test inputs, replacing the not-yet-integrated higher-level service.
- A stub simulates a lower-level module called by the unit under test — it returns canned data. A driver simulates a higher-level module that calls the unit under test — it provides inputs and exercises the UUT. Stubs are passive responders; drivers are active callers.
- Any two: (a) Defect localisation is very difficult — when many tests fail it is unclear which interface caused which failure. (b) All components must be complete before any integration testing begins, eliminating early feedback. (c) Architectural defects are found very late, making rework expensive.
- Advantage: Both the UI and critical back-end modules can be tested early in parallel, combining the benefits of both strategies. Disadvantage: More complex to manage — requires coordination between top-down and bottom-up teams and careful selection of the target (meeting-point) layer.
Summary & Assignment
Session Summary
| Concept | Key Takeaway |
|---|---|
| Integration Testing Purpose | Verifies interfaces and interactions; finds defects invisible to unit tests (format mismatches, protocol errors, state corruption) |
| Two Levels | Component Integration Testing (within subsystem) vs System Integration Testing (between subsystems/external systems) |
| Top-Down | High-level → low-level; uses stubs; early UI test; critical modules tested late |
| Bottom-Up | Low-level → high-level; uses drivers; critical modules tested first; UI tested late |
| Hybrid | Both directions simultaneously; converge at target layer; best for large multi-team systems |
| Big-Bang | All at once; no stubs/drivers; very poor defect localisation; only for tiny systems |
| Strategy Selection | Driven by risk: where are highest-risk components? What can stakeholders see early? Team structure? |
| Modern Patterns | CI-based integration, contract testing (Pact), service virtualisation (WireMock), TestContainers |
Assignment — Lab Task
For the Hospital Information System from the class activity:
- Produce a formal Integration Test Plan (1–2 pages) specifying: scope, strategy chosen (with justification), integration sequence (minimum 6 steps), entry/exit criteria, test doubles needed, environment, and risk register.
- Implement at least 3 integration tests in pytest (or your team's agreed language) for one interface pair of your choice. Use TestContainers or an in-memory DB where applicable.
- Run your tests and capture the output; document any interface defects found.
Marks: 15 points — 5 for integration test plan, 7 for test implementation (correctness, interface focus, no unit-level retest), 3 for defect documentation.
Further Reading
- ISTQB Foundation Level Syllabus v4.0 — Section 4.2: Integration Testing; Section 4.3: System Integration Testing
- Pressman, R.S. (2014). Software Engineering: A Practitioner's Approach, 8th ed. Chapter 22: Integration Testing.
- Richardson, C. (2018). Microservices Patterns. Chapter 9: Testing Microservices. (Contract testing, service virtualisation)
- Pact documentation: docs.pact.io
- TestContainers: testcontainers.com