What is integration testing?
Integration testing -- also known as integration and testing (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 may be coded by different programmers.
The aim of integration testing is to test the interfaces between the modules and expose any defects that may arise when these components are integrated and need to interact with each other.
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 behaviour as a combined, or integrated, unit. Verifying if the individual units are communicating with each other properly and working as intended post-integration is essential.
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. They also use integration-testing tools, including the following:
- Selenium is an open source suite that facilitates automated web application testing.
- Pytest is a Python testing tool which, according to Pytest.org, enables small tests to be written easily "yet scales to support complex functional testing for applications and libraries."
- IBM's RFT (Rational Functional Tester) is an object-oriented automated functional testing tool for performing automated functional, regression, GUI and data-driven testing.
- Junit is an open source framework designed for writing and running tests for Java and Java Virtual Machine (JVM).
- Mockito is an open source testing framework for Java.
- FitNesse is an open source framework in which software testers, developers and customers can work together to build test cases on a wiki.
- LDRA tools are used for integration testing for organizations requiring verification to compliance standards.
Integration testing is usually done simultaneously with development. But this can create a challenge if the modules to be tested are not yet available.
Integration testing versus unit testing
Integration testing is conducted 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 difference between unit testing and integration testing is that in unit testing, individual modules are tested. In integration testing, these modules are combined and tested as a single unit to check the functionality of the overall application.
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 may 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:
- Integrating disparate modules into a working application: When different developers work on different modules, individuals 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 help ensure that the integrated units function properly as one unit and align with stated requirements. It can also ensure there are no errors between the different interfaces of different modules.
- Ensuring that changing requirements are incorporated into the application: In many real-time application scenarios, requirements can and do change often. These new requirements may not be unit-tested every time, which may 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.
- Eliminating common issues missed during unit testing: Some modules that interact with third-party application program interfaces (APIs) need to be tested to ensure they function properly. This may not be done during unit testing, so integration testing is required.
- Eliminating other common problems: Integration testing also helps eliminate issues, such as inadequate exception handling, API response generation, data formatting, erroneous external hardware interfaces, incorrect third-party service interfaces and error trapping.
Common approaches to integration testing
Four key strategies to execute integration testing are big-bang, top-down, bottom-up and sandwich/hybrid testing. Each approach has benefits and drawbacks.
Big-bang testing: The big-bang approach involves integrating all modules at once and testing them all as one unit.
Big-bang testing's advantages include the following:
- Its suitability for testing small systems.
- Its ease of identifying errors in such systems, saving time and speeding up application deployment.
However, big-bang testing has disadvantages, for example:
- Locating the source of defects can be difficult since 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 are not tested on priority (as they should be).
Top-down 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 are as follows:
- It is easier to identify defects and isolate their sources.
- Testers check important units first, so they are more likely to find critical design flaws.
- It is possible to create an early prototype.
However, disadvantages to top-down testing are as follows:
- The examination of lower-level modules can take a lot of time, so testers may not test them adequately or completely.
- When too many testing stubs are involved, the testing process can become complicated.
Bottom-up 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.
Advantages of bottom-up testing are as follows:
- It is easier to find and localize faults.
- Less time is needed for troubleshooting since testers don't have to wait for all modules to be available for testing.
Meanwhile, disadvantages of this type of testing include the following:
- Testing all modules can take a lot of time, so there may be delays in releasing the final product.
- Critical modules are tested only in the final stages, so testers may miss some defects and developers may not have enough time to fix found defects.
- Testing can be complicated if the software consists of multiple low-level units.
- It is not possible to create an early prototype.
Sandwich/hybrid testing: Sandwich or hybrid 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 it is:
- preferable for testing huge programs like operating systems or other long-term applications.
However, this strategy has the following disadvantages:
- It is complex and costly.
- A higher level of precision and skill are required for this approach.
What are the key steps in integration testing?
The steps involved in integration testing are as follows:
Integration testing example
Consider a video-streaming mobile application. Its core features include the following:
- Sign up/log in.
- View different monthly/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 are 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 help find and fix such errors.
So, after each module is ready, testers conduct unit testing. And once all modules are available, testers test them together to check their interfaces and data flows. If no errors are detected, the end user should be able to successfully complete their transaction.
Learn about threat modeling and DevOps and the benefits of continuous testing to quality assurance teams. Explore Java test frameworks and tools for JDK developers, why you should craft an integration testing plan with quality in mind before quantity and the difference between user acceptance testing and system integration testing.