Unit tests can all pass while the system still fails, because the most common defects in multi-component software live in the seams: one module sends amounts in paise and the other expects rupees; one sends dates as day-month-year and the other parses month-day-year; one returns an empty list where the other expects null. Integration testing is the level that looks specifically at those seams. The interesting decisions are about order: which components do you join first, and what do you use in place of the ones that are not ready yet?
An example system
Take a simplified payroll application for a mid-sized Indian company. It has a hierarchy of modules:
- At the top, a Payroll Run controller that HR triggers each month.
- In the middle, a Salary Calculator and a Payslip Generator.
- At the bottom, low-level components the calculator depends on: Attendance, Tax (TDS) Engine and Statutory Deductions (PF, ESI, professional tax).
Different teams build these, and they will not all be ready at the same time. That is the normal situation, and it is what forces a choice of integration strategy.
Stubs and drivers: the two stand-ins
Before the strategies, two terms. A stub replaces a component that is called. If the Salary Calculator is ready but the TDS Engine is not, a stub TDS Engine returns fixed, predictable tax values so the calculator can be tested. A driver replaces a component that calls. If the TDS Engine is ready but nothing above it is, a driver is a small piece of test code that calls the engine with chosen inputs and checks the outputs.
A simple way to remember it: stubs sit below the thing being tested, drivers sit above it. Modern mocking libraries and service virtualisation tools are sophisticated stubs; a test harness or a unit test framework calling an API is effectively a driver.
Big-bang: join everything at once
Wait until all modules are ready, combine them, and test the whole. It needs no stubs or drivers, which sounds efficient. The problem appears the moment something fails. If the net salary on a payslip is wrong, the cause could be in attendance, TDS, PF, the calculator’s arithmetic, the payslip formatting, or any interface between them. Localising defects becomes slow detective work, and since integration waits for the slowest team, testing starts late and is squeezed.
Big-bang is defensible for small systems with few components, or when components are genuinely simple. For anything larger it tends to produce a painful week in which everything is broken and nobody knows why.
Top-down: start from the controller
Begin with the Payroll Run controller and stub everything beneath it. Then replace stubs one by one with real modules, moving downwards: first the real Salary Calculator (with stubbed Attendance, TDS and deductions), then the real TDS Engine, and so on.
Strengths. The overall flow and control logic are tested early, so design problems at the top are discovered while they are still cheap to fix. An early skeleton of the system exists that can be demonstrated to stakeholders.
Weaknesses. Many stubs are needed, and stubs for complex components are hard to write realistically. A stub TDS Engine that returns a flat 10 percent is easy, but it will not reveal what happens when the real engine applies the new tax regime slabs, or returns an error for a missing PAN. The lowest-level components, often where tricky calculations live, are integrated last.
Bottom-up: start from the foundations
Begin with Attendance, TDS and Statutory Deductions, using drivers to call them. Then integrate the Salary Calculator on top, with a driver above it, then the Payslip Generator, and finally the controller.
Strengths. The complex, calculation-heavy foundations are tested thoroughly and early with real inputs. Drivers are usually easier to write than realistic stubs, especially now that test frameworks act as drivers naturally.
Weaknesses. There is no working end-to-end flow until the very end, so problems with overall design or with the top-level workflow surface late. If the controller’s assumptions about how modules are sequenced are wrong, everyone finds out in the final week.
Sandwich (hybrid): both ends towards the middle
Test the top layer downwards and the bottom layer upwards in parallel, meeting in the middle. The controller is tested with stubs; the TDS and deductions modules are tested with drivers; the Salary Calculator becomes the point where they join. This balances the trade-offs and suits large systems where several teams work in parallel. It needs more coordination and both kinds of stand-in.
Comparing them
| Approach | Stand-ins needed | Finds early | Finds late |
|---|---|---|---|
| Big-bang | None | Little | Almost everything |
| Top-down | Stubs | Control flow, design issues | Low-level calculation errors |
| Bottom-up | Drivers | Calculation and utility errors | Workflow and design issues |
| Sandwich | Both | Both ends | Middle-layer issues, if coordination slips |
How this looks with services instead of modules
These strategies were described originally for modules inside one program, but the logic carries straight over to microservices and external integrations. Testing an order service against a mocked payment service is top-down integration with a stub. Calling a payment service directly from a test suite before any front end exists is bottom-up with a driver. Deploying fifteen services to a shared environment for the first time the week before release is big-bang, with all its usual pain.
Modern practice tends to favour incremental, continuous integration: each service is integrated with its real neighbours as soon as possible, interfaces are pinned down with contract tests, and stubs are used only where a dependency is unavailable or uncontrollable, such as a bank’s UPI sandbox that is down every Sunday. The vocabulary of stubs, drivers and integration order still describes exactly what is going on.
What to check at each seam
Whatever the order, integration tests should focus on the interface rather than re-testing each component’s internal logic. Useful questions at each seam: do both sides agree on units, formats, encodings and time zones? What happens when the called component returns an error, a timeout or an empty result? Are optional fields really optional on both sides? Does a large payload, such as a payroll run for 5,000 employees, cross the interface correctly? These are the questions unit tests on either side cannot answer, and they are where integration testing pays for itself.
Written by the RP Strativa Team. The payroll system and its modules are illustrative.
Leave a Reply