Software Testing Integration Testing
Integration testing checks whether different modules or components of a software system work correctly when they are connected together. Individual units may pass their own tests perfectly, but problems often emerge at the points where those units communicate.
Why Integration Testing Is Necessary
Module A: Calculate order total → Unit tests PASS ✔ Module B: Apply discount → Unit tests PASS ✔ Module C: Process payment → Unit tests PASS ✔ But when A passes total to B, and B passes discounted amount to C... the currency format is wrong! A sends: 1500.0 (float) B expects: "1500" (string) → Integration ERROR — missed by unit tests
Integration testing finds the gaps that exist between individually working components.
Types of Integration Testing Approaches
Big Bang Integration
All modules are combined at once and tested together as a whole system. This is simple to organise but difficult to debug — when something fails, it is hard to know which combination of modules caused the problem.
[Module A] + [Module B] + [Module C] + [Module D]
↓
Test everything together
↓
Bug found — but which module? Unknown.
Incremental Integration
Modules are integrated and tested one at a time. Each new module is added to the already-tested group and tested again. This makes it easy to isolate problems to the newly added module.
Step 1: Test Module A alone Step 2: Add Module B → Test A + B Step 3: Add Module C → Test A + B + C Step 4: Add Module D → Test A + B + C + D When a bug appears → it involves the latest module added
Top-Down Integration
Testing starts from the highest-level module and works downward. Lower-level modules that are not yet ready are replaced by stubs (temporary fake versions).
Level 1: Main Application ←── Start here
|
Level 2: User Interface Module
|
Level 3: Business Logic Module
|
Level 4: Database Module ←── Stub used until ready
Bottom-Up Integration
Testing starts from the lowest-level modules and works upward. Higher-level modules not yet available are replaced by drivers (temporary programs that call the lower modules).
Level 4: Database Module ←── Start here
↑
Level 3: Business Logic Module
↑
Level 2: User Interface Module
↑
Level 1: Main Application ←── Driver used to test Level 4
Sandwich Integration (Hybrid)
Combines top-down and bottom-up approaches. Both ends are tested simultaneously and meet in the middle. This is common in large projects where teams work on different layers in parallel.
Integration Testing Example: Online Food Ordering
Modules: [Menu Display] → [Cart] → [Payment] → [Order Confirmation] → [Email Service] Integration Test Scenarios: ───────────────────────────────────────────────────────────────── TC01: Add item to cart → Verify cart total updates correctly TC02: Apply discount in cart → Verify payment receives reduced amount TC03: Payment success → Verify order confirmation page loads TC04: Order confirmed → Verify confirmation email is triggered TC05: Payment fails → Verify cart is not cleared and user can retry
Integration Testing vs Unit Testing
UNIT TESTING INTEGRATION TESTING ──────────── ─────────────────── Tests one function Tests multiple modules together Fast to run Slower to run Easy to set up Requires module connections Finds bugs in logic Finds bugs in communication Developer runs it Tester or developer runs it
Common Integration Bugs
- Data format mismatches between modules (e.g., date format: "2024-01-15" vs "15/01/2024").
- Incorrect API calls — wrong endpoint, missing parameters, or wrong HTTP method.
- Database connection failures — the business layer cannot reach the data layer.
- Race conditions — two modules updating the same record simultaneously, causing conflicts.
- Incorrect error handling — one module passes an error to another module that does not know how to handle it.
Tools for Integration Testing
- Postman: Tests API integrations by verifying request and response contracts between services.
- REST-assured: A Java library for testing REST API integrations in code.
- Spring Boot Test: For Java Spring applications — tests the integration of Spring components.
- pytest with fixtures: In Python, integration tests use database fixtures to test real data flows.
