Definition

What is integration testing (I&T)?

Integration testing -- also known as integration and testing or I&T -- is a type of software testing in which the different units, modules or components of a software application are tested as a combined entity.

However, these modules can be coded by different programmers.

The aim of integration testing is to test the interfaces between the modules and expose any defects that could arise when these components are integrated and need to interact with each other. By identifying integration problems early in the development process, integration testing reduces the risk of costly issues later.

What does integration testing involve?

Also known as string testing or thread testing, integration testing involves integrating the various modules of an application and then testing their behavior as a combined, or integrated, unit. It's essential to verify that the individual units are communicating with each other properly and working as intended post-integration.

To perform integration testing, testers use test drivers and stubs, which are dummy programs that act as substitutes for any missing modules and simulate data communications between modules for testing purposes.

While integration testing can be performed manually by quality assurance alongside development teams, this approach isn't always ideal. Automated testing using frameworks or tools can greatly accelerate the process and allocate resources more effectively.

The following are examples of tools that are used for integration testing:

  • FitNesse is an open source framework in which software testers, developers and customers can work together to build test cases on a wiki.
  • Jasmine is a development framework for testing JavaScript.
  • JUnit is an open source framework designed for writing and running tests for Java and Java virtual machine.
  • LDRA tools are used for integration testing for organizations requiring verification to compliance standards.
  • Mockito is an open source testing framework for Java.
  • Pytest is a Python testing tool that, according to Pytest.org, enables small tests to be written easily yet scales to support complex functional testing for applications and libraries.
  • IBM Rational Integration Tester is an object-oriented automated functional testing tool for performing automated functional, regression, graphical user interface and data-driven testing.
  • Selenium is an open source suite that facilitates automated web application testing.
  • Steam, developed by GitHub, is an open source framework used to test JavaScript-enabled websites.

Integration testing is usually done simultaneously with development. However, this can create a challenge if the modules to be tested aren't yet available.

Integration testing versus unit testing

Integration testing serves as a crucial link in the software development lifecycle. It's conducted before system testing and after unit testing, where the functional correctness of the smallest piece of code, or unit, is tested. Each unit can be logically isolated in the software. The smaller the unit, the more granular insights unit testing can reveal.

The main differences between unit testing and integration testing include the following:

  • Unit testing is a type of white box testing, while integration testing is considered a form of black box testing.
  • In unit testing, individual components or units of code are tested. The goal is to ensure that each unit functions correctly on its own, without dependencies on other parts of the system.
  • In integration testing, these modules are combined and tested as a single unit to check the functionality of the overall application.
  • Integration tests are broader and more complex than unit tests, as they assess interactions between different components or subsystems and can involve testing entire systems or subsystems.
  • Unit tests avoid relying on external systems by using mocks or stubs to simulate dependencies, ensuring speed and reliability.
  • Integration tests interact with external systems such as databases or application programming interfaces (APIs), making them slower and requiring more setup and resource allocation.
  • Unit tests are usually run frequently, often with each code change or commit to ensure that new updates don't disrupt existing functionality.
  • Integration tests are typically run less frequently, often as part of a continuous integration pipeline or before major releases to ensure the system functions correctly as a whole.
A chart showing the continuous integration process.
Continuous integration enables developers to merge code changes into a central repository.

Why integration testing is essential

Integration testing is vital in today's IT and software development landscapes, especially when requirements are dynamic and deadlines are tight. Even when each module of the application is unit-tested, some errors can still exist. To identify these errors and ensure that the modules work well together after integration, integration testing is crucial.

Key reasons to conduct integration testing include the following:

  • Integrates disparate modules into a working application. When different developers work on different modules, they bring their own understanding and logic to the development effort. This can cause functional or usability problems when the modules are combined. Integration testing can ensure the integrated units function properly as one unit and align with stated requirements.
  • Identifies interface issues. Integration testing can also ensure there are no errors between the different interfaces of different modules, as modules can have dependencies and communicate through interfaces during integration. Integration testing identifies issues with data flow, network communication protocols and interface mismatches that could cause system failures or unexpected behavior.
  • Ensures that changing requirements are incorporated into the application. In many real-time application scenarios, requirements can and do change often. These new requirements might not be unit-tested every time, which could lead to missed defects or missing product features. Integration testing can fill in these gaps to ensure that new requirements are incorporated into the final application.
  • Eliminates common issues missed during unit testing. Some modules that interact with third-party APIs must be tested to ensure they function properly. This might not be done during unit testing, so integration testing is required.
  • Eliminates other common problems. Integration testing also eliminates issues such as inadequate exception handling, API response generation, data formatting, erroneous external hardware interfaces, incorrect third-party service interfaces and error trapping.
  • Supports continuous delivery. In DevOps and modern test environments with continuous integration practices, integration testing is crucial for ensuring that new code changes don't disrupt existing functionality. This keeps the codebase stable as well as supports Agile software development and testing methods.

Types of integration testing

Four key strategies to execute integration testing are big-bang, top-down, bottom-up and sandwich/hybrid testing. Each approach has its benefits and drawbacks.

Big-bang integration testing

Big-bang integration testing involves integrating all modules at once and testing them all as one unit.

Big-bang testing's advantages include the following:

  • It's suitable for testing small systems.
  • It can easily identify errors in such systems, saving time and speeding up application deployment.

However, big-bang testing has the following disadvantages as well:

  • Locating the source of defects can be difficult, as different modules are integrated as one unit.
  • Big-bang testing is time-consuming for a large system with numerous units.
  • Testers could miss some interface links or bugs.
  • Testers must wait until all modules are available, so they have less time to do the testing and developers have less time to fix any errors.
  • Due to simultaneous testing, high-risk critical modules and peripheral modules dealing with user interfaces aren't tested on priority as they should be.

Top-down integration testing

The top-down approach is an incremental approach that involves testing from the topmost or highest-level module and gradually proceeding to the lower modules. Each module is tested one by one and then integrated to check the final software's functionality.

Advantages of top-down testing include the following:

  • It's easier to identify defects and isolate their sources.
  • Testers check important units first, so they're more likely to find critical design flaws.
  • It's possible to create an early prototype.

However, the disadvantages of top-down testing include the following:

  • The examination of lower-level modules can take a lot of time, so testers might not test them adequately or completely.
  • When too many testing stubs are involved, the testing process can become complicated.

Bottom-up integration testing

Bottom-up -- also known as bottom-to-top -- integration testing is the opposite of the top-down approach. It involves testing lower-level modules first, and then gradually progressing incrementally to higher-level modules. This approach is suitable when all units are available for testing.

The advantages of bottom-up testing include the following:

  • It's easier to find and localize faults.
  • Less time is needed for troubleshooting, since testers don't have to wait for all the modules to be available for testing.

Meanwhile, disadvantages of this type of testing include the following:

  • Testing all software modules can take a lot of time, so there can be delays in releasing the final product.
  • Critical modules are tested only in the final stages, so testers might miss some defects and developers might not have enough time to fix found defects.
  • Testing can be complicated if the software consists of multiple low-level units.
  • It isn't possible to create an early prototype.

Sandwich or hybrid testing

Sandwich or hybrid integration, also known as mixed integration testing, combines the top-down and bottom-up approaches. It uses both stubs and drivers.

The advantage of sandwich or hybrid testing is that preferable for testing huge programs such as operating systems or other long-term applications.

However, this strategy also has the following disadvantages:

  • It's complex and costly.
  • A higher level of precision and skill are required for this approach.
A diagram showing four integration testing types.
Integration types include big-bang, top-down, bottom-up and hybrid.

What are the key steps in integration testing?

The steps involved in integration testing are as follows:

  1. Prepare the test plan by outlining the scope, objectives and resources as well as the integration testing approach.
  2. Design integration test cases, test scenarios, use cases and scripts that focus on the interactions between modules.
  3. Set up the testing environment by configuring necessary hardware, software and network settings.
  4. Run tests after unit or module integration.
  5. Detect, report and fix errors encountered during testing with detailed information about the failures and the conditions under which they occurred.
  6. Retest functionalities after fixing bugs and perform regression testing to ensure other defects weren't introduced into other parts of the system.
  7. Repeat the integration testing process until all bugs in the test results are found and fixed.
  8. Evaluate the overall integration testing after all defects are fixed.
  9. Prepare a report summarizing integration testing activities, including test coverage, defect statistics and the overall quality assessment of the integrated system to inform stakeholders and guide future testing efforts.

Integration testing example

The following example illustrates how integration testing is applied in a mobile application.

Consider a video-streaming mobile application. Its core features include the following:

  • Sign up and log in.
  • View different monthly and yearly subscription plans.
  • Choose personalized plans.
  • Watch streaming video.

Once users download the applications, they see a sign-up form where they can enter their account information. After successful authorization, they're redirected to a page listing different subscription plans. They can choose their own plan and then complete the payment.

Any errors in this logical flow could cause problems for the user and lead to losses for the app company. Integration testing can find and fix such errors.

After each module is ready, testers conduct unit testing and once all modules are available, they test them together to check their interfaces and data flows. If no errors are detected, the end user should be able to complete their transaction successfully. This ensures that each access component of the app is working seamlessly.

Properly executed, infrastructure as code (IaC) boosts continuous delivery pipelines, but untested code can cause problems. Follow these strategies to test IaC with success.

This was last updated in October 2024

Continue Reading About What is integration testing (I&T)?

Dig Deeper on Software design and development