Sandwich Approach

The Sandwich Approach (also called the Hybrid Approach) in Component Integration Testing is a combination of Top-Down and Bottom-Up integration testing strategies. It is used when a system has multiple layers (e.g., a three-tier architecture: UI, Business Logic and Database).

How It Works:

  1. Top-Down Testing:
    • Starts testing from higher-level modules (e.g., UI or business logic) and integrates downward.
    • Uses stubs to simulate lower-level components that are not yet developed.
  2. Bottom-Up Testing:
    • Simultaneously, lower-level modules (e.g., database or APIs) are tested and integrated upward.
    • Uses drivers to simulate higher-level modules that are not yet developed.
  3. Final Integration:
    • Once both top and bottom modules are tested, they are merged at a middle layer and tested together.

Advantages:

  • Parallel Testing: Top and bottom layers are tested simultaneously, speeding up the process.
  • Early Defect Detection: Issues in both higher-level and lower-level components can be identified early.
  • More Balanced: Overcomes the limitations of using only top-down or bottom-up approaches.

Disadvantages:

  • Complex Implementation: Managing stubs and drivers at different layers can be challenging.
  • Higher Resource Requirements: Requires more effort to develop both stubs and drivers.

When to Use the Sandwich Approach?

  • Large, multi-layered applications (e.g., enterprise software with UI, business logic and database layers).
  • Systems requiring parallel development of high and low-level modules.
  • Projects with strict deadlines, where waiting for full module completion isn’t feasible.