What is Sandwich Testing- Features and Example

May 10, 2024Idowu Paul
What is Sandwich Testing- Features and Example

Start automating your tests 10X Faster in Simple English with Testsigma

Try for free

Unit testing, followed by integration testing validates software quality. But when building a robust enterprise application, your integration testing approach needs some more push. For software connected to other sub-projects, quality validation requires back-to-back, reverse-forward testing of all layers of your application from the onset. This is where sandwich testing comes in.

This blog will explain the sandwich testing concept, including its features and the steps to execute it.

What Is Sandwich Testing?

Sandwich testing is an integration testing method that involves splitting an application into different layers and testing them separately and integrally to ensure each layer works perfectly to meet the software specifications. You can also refer to a sandwich test as hybrid integration testing since it combines the top-down and bottom-up testing approaches. Sandwich testing is an incremental testing process, and it assumes a three-layer testing pattern with the middle layer as the target layer.

The Top-Down Testing Approach

The top-down approach starts testing from the middle layer (target) to the lower modules. Here, you begin with the independent validation of individual units of the target layer, followed by a gradual integration of the lower modules, usually the database and other external services. 

The lower modules are usually stubbed (simulated) to provide dummy data and objects to mimic them. This helps verify if the validated component of the target layer behaves as expected when mounted on lower subsystems.

The Bottom-Up Approach

On the other hand, the bottom-up approach begins testing from the middle layer to the upper modules. This approach first evaluates the upper part in isolation and gradually tests it when integrated with the validated middle subsystem to catch bugs as the test proceeds. You can think of the upper layer in context as a simulated UI.

Sandwich Testing and the N-Tier Software Architecture

An N-tier software architecture using a three-tier typically features the client side, business logic, and data access. You test each layer independently and further validate how they communicate after integration. That’s the sandwich testing concept. Ultimately, it helps mitigate bugs and save development time. Additionally, it makes your test suite more scalable since there are different test layers.

For instance, while ensuring that the submit button in the UI works, you also want to ensure that it calls the appropriate function, sends the expected queries to the database, and executes the associated algorithm expectedly on the returned data. Regardless of your application’s complexity, the sandwich testing method helps your test assess its entire architecture without complicating your test suite.

Features of Sandwich Testing

Here are the key features of sandwich testing. 

  • Sandwich testing is granular: It’s specific to each component or feature of an application. Thus, it involves independently testing individual components and how they further communicate with the corresponding subsystems. Invariably, it ensures each application component satisfies its expected quality first and checks how it behaves when it works with its associated layers.
  • It assumes a three-layer testing pattern: Sandwich testing takes the bottom-up and top-bottom approach, with the target layer is typically in the middle.
  • It is complete: Sandwich testing has extended coverage, combining integration and unit testing to validate the target layer independently first. It then verifies how it works when integrated with the associated upper and lower layers.
  • It modularizes the test suite: Sandwich testing ensures that the test suit handles each part of an application under test independently, separating component concerns into modules that can run independently. 
  • Sandwich testing is incremental: Sandwich testing typically starts with the target module and progresses to other components in a forward and reverse pattern (from middle to top and from middle to bottom).

Why is sandwich testing necessary in software testing?

The ultimate goal of sandwich integration testing is to ensure that each subsystem of your application works together to achieve an overall quality. While it might be costly and complex, you want to use this testing method for the following reasons.

  • Earlier bug detection: It helps catch potential bugs earlier, saving development time and mitigating financial loss from production bugs.
  • Improved test coverage: It helps you perform both unit and integration testing simultaneously to discover the effect of integrating other subsystems on the target layer. So, it improves the test coverage and software quality.
  • Test scalability and reusability: Since each test module handles the application’s components individually, sandwich testing makes it easy to add more tests and reuse existing ones as your application scales. Thus, it’s robust and ideal for testing applications with complex architecture.
  • Reduced test suite complexity: Sandwich testing adopts a descriptive naming convention, making locating the module that handles a specific test easier. It also makes your tests more comprehensive when shared with your team.
  • Support for parallel testing: You can test modules in parallel since many modules are under test. This saves time significantly.
  • Support for test automation: Like conventional end-to-end testing, sandwich testing is also subject to automation testing tools like Testsigma, Selenium, Appium, Playwright, and many more.

Sandwich testing and test automation

Automating your sandwich testing is helpful when:

  • Considering the complexity of sandwich testing, automation simplifies the process
  • Test automation improves the test feedback cycle, allowing the development team to evaluate test results more efficiently. 
  • Automation testing is saving costs, some avenues where costs can be saved are:
    • It simulates different testing environments, including browsers and operating systems.
    • It helps you track the test step that fails during testing. This is handy for quick bug fixing.
    • It helps keep track of the test for continuity and scalability.
    • Automating your sandwich test provides an avenue for parallel multi-platform and multi-browser testing.

Some Tools to Automate Sandwich Testing

  • Testsigma: Testsigma is an automation testing platform that allows you to automate UI tests locally or in the cloud without coding, in simple English. With support for multi-browser and multi-device testing, you can run tests in parallel using Testsigma’s Test Lab. In addition to browser extensions for recording tests, it features a user-friendly interface for creating test scenarios and writing test steps for each. It supports web, mobile, and API testing with little maintenance overhead, as tests are in plain English script. 

  • Selenium: Selenium is an open-source framework for automating user interactions on the web. Selenium provides web drivers for modern browsers, including Chromium-based browsers, Firefox, and Safari, and it’s the most-used testing framework. As of writing, Selenium has approximately 206,000 users, according to its GitHub stat. The framework also features an IDE for playback test automation and supports the Selenium Grid for orchestrating tests in multiple environments. Selenium test automation requires coding experience in its supported languages, including Python, Kotlin, Ruby, Java, JavaScript, and C#.

  • Playwright: Playwright is Microsoft’s end-to-end testing framework for automating web actions. In contrast to Selenium, GitHub puts its users’ stat at 26,000. Compared to Selenium, Playwright is more recent and supports fewer programming languages, including JavaScript, Python, TypeScript, .NET, and Java. It also supports many modern browsers and allows parallel testing. Unlike Selenium, which requires an implicit wait for DOM loading, Playwright features auto-wait and web-first assertions. The framework also has a code generator. In addition to helping set up tests quickly, this can be handy for generating relevant web element selectors during testing to save element inspection time.

Example of Sandwich Testing

Every application has different components performing different functions. Each part typically communicates with the lower subsystems. These include the business logic and data layers. 

In sandwich testing, the application validation is typically incremental. It ensures you verify one module after another when integrated with the top layers. 

While performing sandwich testing, you typically start by testing the UI using stubs to simulate test data. Here, you might want to use UI testing tools like Testsigma to simulate a UI to validate the target component.

Once you test the UI, you can start testing the lower modules independently using drivers to simulate unavailable modules. Once done, you’ll integrate each validated lower module with the UI and rerun the test. This is the integration testing phase. It verifies if the application works expectedly after mounting each module.

For example, while testing a complex application using the sandwich approach, you want to validate each lower module in isolation before integrating it with the target (the UI). Next, you’ll rerun the test after integrating the UI with the previously validated module. This is to validate that each module works as expected when mounted on the UI. 

You then repeat the process for each lower module until your test satisfies the required quality. However, modules that are unavailable for testing are usually stubbed.

How to run a sandwich test?

Sandwich testing requires close attention to the detail of your application. The following steps are a guide for executing a sandwich test.

Step 1: Create your test scenarios: Planning a test scenario helps you imagine a user story. Your test scenario must be complete, comprehensive, and realistic and should include concise test steps.

Step 2: Prioritize the essential modules: Identifying the target components makes your tests more specific and consistent. Ensure you collaborate with the development team to understand underlying functions and modules. This helps you to verify which modules are available for testing and efficiently create test stubs and drivers for them. At this stage, you also want to identify and prioritize the modules in the order of their effect on your application’s functionalities.

Step 3: Choose a testing environment: This is where you decide whether to run manual or automation testing. While automating your test, you should also determine whether to use a local web driver or spin it up using a cloud grid.

Step 4: Run your UI test in isolation: Start your sandwich testing by running the UI test in isolation with stubs.

Step 5: Test each module independently: Here, you’ll test each lower subsystem in isolation to ensure they meet the software quality requirements. You might want to run subsystem tests in parallel to save time and cost.

Step 6: Perform integration testing on mounted modules: After testing each module and the UI independently, integrate the UI with each module and rerun the test.  

Step 7: Evaluate test results: Use various test coverage and analytic tools to estimate how well your test performed. A critical evaluation of the test coverage helps you identify further test requirements. You can also generate shareable HTML coverage reports to view the missing tests.


Despite the independence of each layer during development, they intertwine and work together when shipped to the end user. Bugs in one of the layers can break the whole. Thus, a layered architecture requires unsullied testing to ensure all parts meet software quality standards and user experience expectations. 

Unlike integration testing, that only tests the software when systems are mounted, sandwich testing is more comprehensive, as it checks each layer separately before integrating them incrementally with the target layer.

Frequently Asked Questions

What is hybrid or sandwich integration testing?

Hybrid or sandwich integration testing is an incremental software testing method for validating if an independently tested lower module works as it should when integrated with higher systems you’ve also tested in isolation. 

What are the attributes of sandwich testing?

Sandwich testing has many attributes. But for the most part, it’s complete, stepwise, incremental, unassuming, modular, and pays strict attention to the application details. Overall, it makes your test suite reusable and more scalable.

Subscribe to get all our latest blogs, updates delivered directly to your inbox.


Types of Testers: A Comprehensive Guide 
Automated Test Oracles in Software Testing
Accelq vs Provar | Which One You Should Choose?