Open In App

Sandwich Testing - Software Testing

Last Updated : 01 May, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Sandwich Integration Testing helps verify that software works reliably in complex systems with multiple layers. It combines both top-down and bottom-up testing methods, giving a thorough check of the system. This approach looks at individual layers and how they interact, catching defects early on, reducing risks, and improving the overall quality of the software.

Here we are learning the Sandwich testing important topics:

What is Sandwich Testing?

Sandwich Testing combines the bottom-up and top-down approaches, so it uses the advantages of both the bottom-up and top-down approaches. Initially, it uses the stubs and drivers where stubs simulate the behavior of a missing component. It is also known as Hybrid Integration Testing.

sandwich-testing
Sandwich Testing

The purpose of sandwich testing is to provide full and efficient coverage across the software system. Here is the some mentioned bellow:

  1. Entire Coverage: Sandwich testing tests a system's high-level and low-level modules concurrently to give full coverage.
  2. Early Integration Problem Identification: It assists in identifying integration problems early in the testing process by testing from both ends and coming together in the middle.
  3. Incremental Testing: It is compatible with the incremental testing methodology, which integrates and tests components one at a time. This steady technique can help manage a large software system's complexity.
  4. Effective Use of Resources: Sandwich testing uses testing resources more effectively by testing components simultaneously.
  5. Component Interface Verification: The connections between high-level and low-level components are verified by sandwich testing.
  6. Testing and Development in Parallel: Testing and development can happen in parallel because of sandwich testing. High-level and low-level modules can be worked on by developers simultaneously and testing can start before all components are finished.

Learn More: Software Testing | Basics

Strategy used in Sandwich Testing

The strategy is simple but powerful. Sandwich testing works in layers:

1. It combines both top-down and bottom-up strategies. 

2. Sandwich testing is basically viewed as 3 layers: 

  1. The Main Target Layer: This is the middle layer that gets tested after both the top-down and bottom-up tests.
  2. The Layer Above the Target: This layer is tested using the top-down approach.
  3. The Layer Below the Target: This layer is tested using the bottom-up approach.

3. In sandwich testing, testing is mainly focused on main target layer. This testing is selected on the basis of system characteristics and structure code.  

4. It tries to minimize the number of hubs and drivers when there are more than 3 layers. 

How to Perform Sandwich Testing? 

There are 3 simple steps to perform sandwich testing which are given below:

  1. Test the User Interface (UI) in Isolation: Use stubs (simulated components) to test the UI first. This allows you to check the higher-level aspects of the software before the backend systems are fully ready.
  2. Test the Lowest-Level Functions: Use drivers (components that simulate higher-level functions) to test the low-level modules. This allows testing the foundation of the system, even if the top layers aren’t yet complete.
  3. Final Integration Testing: Once both the high and low-level tests are done, test the middle (main target) layer when the full system is integrated. This verifies that everything works together as expected.

For Example: 

When to Use Sandwich Testing

Sandwich testing works best in situations like these:

  1. For Large, Complex Systems: If you're working on a system with lots of interconnected parts, Sandwich testing is a great choice. It helps verify that both the high-level and low-level modules are working well together, making sure the system functions as a whole.
  2. When You Need Parallel Testing: If your development and testing need to happen at the same time, Sandwich testing is perfect. It lets you test both ends of the system while the middle layer is being developed, so everything can progress smoothly and without unnecessary delays.
  3. To Catch Issues Early: Sandwich testing breaks the system down into manageable pieces and starts testing early. This helps identify problems much sooner in the process, instead of waiting for everything to be fully integrated. This way, you can fix issues as they come up and avoid bigger problems later on.

Advantages of Sandwich Testing

Here are the main advantages of Sandwich testing:

  1. Sandwich Testing approach is used in very large projects having subprojects.
  2. It allows parallel testing.
  3. It is a time-saving approach.
  4. It performs more coverage with same stubs.
  5. It can be used to test both the functional and non-functional aspects of a system.
  6. It can be used to test systems with complex dependencies.
  7. It can be used to test systems with complex data structures.
  8. It can be used to test systems with complex algorithms.
  9. It is an effective way to test both the functionality and the performance of an application.
  10. It is a well-defined process that can be easily repeated and documented.
  11. It can be used to test applications of all sizes and complexity.
  12. It is an efficient way to test applications that have a lot of functionality.

Disadvantages of Sandwich Testing

Sandwich testing does come with a few drawbacks which are bellow:

  1. Sandwich Testing can not be used for such systems which have a lot of interdependence between different modules.
  2. In sandwich testing the need for stubs and drivers is very high.
  3. It is expensive to set up and maintain the necessary infrastructure.
  4. here is a risk that the test environment may not be representative of the production environment, which could lead to inaccurate results.
  5. There is a potential for human error when manually transferring data between the two environments.

Conclusion

Sandwich testing is a great way to make sure your software works smoothly, especially when you're dealing with complex systems that have many layers. By combining top-down and bottom-up testing, it provides a well-rounded approach to testing both individual parts of the software and how they interact with each other.


Next Article

Similar Reads