Open In App

Difference between Unit Testing and Sandwich Testing

Last Updated : 24 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Unit Testing: Unit Testing is the type of Software Testing level in which each individual components of a software are tested. Unit Testing is generally performed by the developer. Unit Testing can’t be used for those systems which have a lot of interdependence between different modules. It does not allow for parallel testing.

Sandwich Testing: Sandwich Testing is also known as hybrid integration testing. Sandwich Testing comprises the bottom-up approach testing and top-down approach testing, therefore it uses the advantage of both the bottom-up approach and top-down approach. Sandwich Testing also can not be used for those systems that have a lot of interdependence between different modules and it allows parallel testing. of interdependence between different modules and it allows parallel testing.  

Sandwich-Testing
Sandwich Testing

Difference between Unit Testing and Sandwich Testing

Here is the Difference between Unit Testing and Sandwich Testing

S.NOUnit testingSandwich testing
1. In unit testing, software module are tested separately.Sandwich testing comprise the top-down and bottom-up testing.
2. Defects are identified easily in unit testing.Defects are not identified easily in sandwich testing testing.
3. In Unit testing does not matter how big project is.Sandwich Testing is used for very large projects having sub projects.
4. Unit testing is cost efficient.Sandwich testing is not cost efficient.
5. Unit testing does not allow parallel testing.Sandwich testing allows parallel testing.
6.Unit Testing can’t be used for those systems which have a lot of interdependence between different modules.Sandwich Testing also can not be used for those systems which have a lot of interdependence between different modules.
7.In Unit testing, there is need of fewer resources for testing.In Sandwich testing, there is need of large number of resources.
8.Unit testing is typically done by developers.Sandwich testing is done by both developers and testers.
9.Unit tests are typically done early in the development process.Sandwich tests are done later.
10.Unit tests are usually small and focused.Sandwich tests are larger and more comprehensive.
11.Unit tests are used to verify the functionality of individual units.Sandwich tests are used to verify the functionality of the system as a whole.
12.Unit tests are typically run manually.Sandwich tests may be run automatically.
13.Unit tests are typically written in the same language as the code being tested.Sandwich tests may be written in a different language.
14. Unit tests typically focus on functional testing.Sandwich tests may also include non-functional testing.
15.Unit tests are typically not concerned with scalability.Sandwich tests may include scalability testing.
16. Unit tests are typically not concerned with usability.Sandwich tests may include usability testing.
17.Unit tests are typically run on the development environment,.Sandwich tests are usually run on the production environment.
18.Unit tests are typically black box tests.Sandwich tests may be white box tests.
19.Unit tests typically do not require knowledge of the internals of the code being tested.Sandwich tests may require knowledge of the internals.
20. Unit tests are typically limited to a single component. Sandwich tests may span multiple components.
21.Unit tests are typically used to find bugs, Sandwich tests are also used to verify system quality.

What is unit testing?

Unit testing is the process of testing the smallest parts of your code, like individual functions or methods, to make sure they work correctly. It’s a key part of software development that improves code quality by testing each unit in isolation.

Workflow-of-Unit-Testing
Workflow of Unit testing

You write unit tests for these code units and run them automatically every time you make changes. If a test fails, it helps you quickly find and fix the issue. Unit testing promotes modular code, ensures better test coverage, and saves time by allowing developers to focus more on coding than manual testing.

Unit Testing Techniques

 There are 3 types of Unit Testing Techniques. They are follows

  1. Black Box TestingThis testing technique is used in covering the unit tests for input, user interface, and output parts.
  2. White Box TestingThis technique is used in testing the functional behavior of the system by giving the input and checking the functionality output including the internal design structure and code of the modules.
  3. Gray Box TestingThis technique is used in executing the relevant test cases, test methods, and test functions, and analyzing the code performance for the modules.

What is Sandwich Testing?

Sandwich Testing combines the bottom-up and top-down approaches, so it uses the advantage 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.

Strategy Used in Sandwich Testing

Sandwich Testing combines both top-down and bottom-up strategies. It can be thought of as having three layers:

  1. Main Target Layer
  2. Layer Above the Target Layer
  3. Layer Below the Target Layer

In Sandwich Testing, the focus is mainly on the main target layer, where the testing is conducted. The approach is chosen based on the system's characteristics and the structure of the code.

When there are more than three layers, Sandwich Testing aims to reduce the number of hubs and drivers needed for testing, making the process more efficient.

When to Use Unit Testing and Sandwich Testing

Unit Testing is best used when:

  • You need to test individual functions or methods.
  • You want to make sure small, isolated parts of your code work correctly.
  • You’re in the early stages of development and want to catch bugs early.

Sandwich Testing is best used when:

  • You need to test how different modules interact within the system.
  • You’re working with a large and complex system with many interconnected components.
  • You want to ensure the modules work well together from both the top and bottom levels.

Conclusion

Both Unit Testing and Sandwich Testing are essential for ensuring high-quality software. Unit Testing focuses on testing individual components, while Sandwich Testing looks at how different modules work together. By knowing when to use each method, developers can create robust, reliable software that meets user expectations.


Next Article

Similar Reads