Updated Jul 23, 2024 15 min read
How To Do Integration Testing: A Detailed Guide
Integration testing is when software modules are tested as a group and logically combined. This guide provides insights on how to write integration tests effectively, ensuring robust software functionality.
![How To Do Integration Testing: A Detailed Guide](https://luxequality.s3.amazonaws.com/Articles/HowToDoIntegrationTesting.png)
Integration testing is when software modules are tested as a group and logically combined. The software product consists of several software modules written by different programmers. Such testing aims to detect errors in the interaction between these modules. The approach relies on checking data exchange between these modules themselves. Therefore, practitioners also refer to it as "I&T" (Integration and Testing), "String Testing," or sometimes "Thread Testing."
This guide provides insights on how to write integration tests effectively, ensuring robust software functionality. We discuss integration tests' role, use, and situations when relying on classic unit tests is better. Also, we touch upon the compelling writing, their implementation, and the stages of how to do integration testing.
Integration testing in theory
Unit tests are great for testing the functionality of a module or feature, but it is not enough to check this logic "in a vacuum". It is also necessary to check how its various parts integrate with external systems.
If mocks replace all external dependencies, there won't be any shared dependencies between modules. As a result, these tests will maintain their speed as long as the modules support isolation from each other, essentially becoming unit tests. However, many applications have an out-of-process dependency that mock cannot replace. This is usually a database, a dependency not visible to other applications.
It is essential to maintain a balance between unit and integration tests. Working directly with out-of-process dependencies slows down integration tests. In addition, they are also more expensive to maintain.
On the other hand, integration tests go through a more significant amount of code, making them more effective in bug protection than unit tests. They are also more separated from the working code and, hence, have more resistance to its refactoring.
The ratio between unit and integration tests depends on the specifics of the project, but the general rule is as follows: test as many boundary values of the business scenario as possible with unit tests; use integration tests to cover one positive path as well as all boundary values that are not covered by unit tests.
Why is integration testing needed?
In software testing, integration testing represents one phase of the testing cycle.
![](https://luxequality.s3.amazonaws.com/Articles/WhyIsIntegrationTestingNeeded.png)
Integration testing is becoming an integral part of the software quality assurance process for the following reasons:
Diversity of modules and developers: Since software modules are often developed by different specialists, differences in understanding and programming logic can lead to unpredictable interactions between them. Integration testing is necessary to verify the correctness of their interactions.
Changing requirements: During the development of a module, customers often change the requirements, which may affect the module's functionality. In situations where time is constrained and unit testing is not yet developed for a module to be deployed, integration testing plays a crucial role in detecting potential issues in system integration.
Errors in database interfaces: Interfaces of program modules with databases may contain errors such as incorrect queries or data processing problems. Integration testing helps to identify such problems and ensures correct interaction with the database.
Errors in external hardware interfaces: If external hardware interfaces are present in software modules, errors in these interfaces may lead to unpredictable system behavior. Integration testing can detect and correct such problems.
Incorrect exception handling: This can lead to failures and undesirable behavior of the system as a whole. Integration testing involves checking the correctness of exception handling in module interactions.
Thus, integration testing plays a crucial role in detecting and eliminating problems that may occur at the stage of interaction between different software components.
How to do integration testing with example
Now, let's dive into how to write an integration test, starting with defining test cases.
Example 1: Integration testing in an online store:
In this case, the main focus is testing the correct interaction between the "Order placement" and the "Warehouse accounting" modules. This includes transferring order information from the Checkout module to the Warehouse Accounting module. The focus here is on two modules: "Checkout" and "Warehouse Accounting".
Example 2: Integration testing in online banking:
In this case, the focus is testing the correct integration between the "Authorization" module and "Personal Cabinet". The main task is to ensure that the user's data is displayed correctly in the personal cabinet after successful authorization. The focus is also on two modules: "Authorization" and "Personal Cabinet".
Test | Purpose of the test case | Description of the test case | Expected result |
---|---|---|---|
1 | Ensure correct interaction between the Checkout and Warehousing module when placing a new order. | Add a product to the cart on the Checkout page. When the checkout is complete, verify that the new order information is transferred and displayed correctly in the "Warehouse Accounting" module. | The stock control system must register the new order successfully and reduce the corresponding quantity of goods in stock. The system must make all order information accessible for further processing. |
2 | Ensure proper integration between the "Authorization" module and "Personal Office" when the user logs in. | Enter the correct credentials on the authorization page. After successful authorization, ensure the interface redirects the user to the personal account and displays the appropriate user information. | Upon successful authorization, redirect the user to the personal account page. Ensure that the information in the personal cabinet matches the user data entered during authorization. |
Both tests concentrate on the interaction of two key modules. In the first case, the modules are "Checkout" and "Warehouse Accounting" within the context of an online store, and in the second case, they are "Authorization" and "Personal Area" within an online bank. The modules must accurately transfer and display data in both instances to guarantee the system's correct functionality.
Don't let mistakes become a disaster! Our tests will help your project.
How to run integration test: Strategies, methodologies, and approaches
QA engineers use various integration testing strategies. How to integration testing the use following approaches:
Big Bang integration is one major test for the entire system at once.
Top-down Integration of the system's upper levels before gradually incorporating lower levels.
Bottom-up integration starts with the lower levels, gradually incorporating higher levels of the system.
Sandwich - A combination of top-down and bottom-up, a blended approach that incorporates elements of both previous methods.
Below, we discuss the strategies of the different implementation methods and the limitations and advantages of each approach. Let's look at how to run an integration test in a real-world scenario.
Big Bang integration testing
Big Bang Testing is an approach to integration testing in which all system components are integrated simultaneously and tested as a whole.
Advantages:
- Easy to implement.
- Suitable for small systems.
Disadvantages:
- Difficulty in localizing faults. One of the main disadvantages of the Big Bang test is the difficulty in localizing faults. Identifying the component responsible for a detected fault during testing can be challenging and requires additional tests to isolate the fault.
- There is a high risk of missing bugs due to the large number of interfaces. Another problem with Big Bang testing is the risk of missing bugs due to the large number of interfaces. Testing a system involves examining all potential combinations of interfaces. Not testing some combinations may result in overlooking a bug in that specific combination.
- Additional time for testing is necessary. Big Bang testing can be time-consuming since integration testing can only start after finalizing all modules. This situation can pose challenges if the testing team has a constrained timeframe for conducting tests.
- Lack of prioritization in testing critical. Big Bang Testing does not enable prioritized testing of critical modules and modules with user interfaces. This may result in testing these modules later when addressing issues becomes more challenging and time-consuming.
Additional nuances:
- The Big Bang testing can be practical if the system has several components that interact well.
- This approach is beneficial for systems that have complex or unique interfaces.
- The Big Bang testing can be ineffective or even dangerous if the system consists of many components or modules or if the interfaces between them are complex.
Conclusion
Big Bang testing is a simple and practical approach to integration testing for small systems. However, this approach can be ineffective or even dangerous if the system consists of many components or modules or if the interfaces between them are complex.
Bottom-up integration testing
Bottom-up integration testing is an approach in which system modules are integrated and tested during development. This approach starts by testing the lower-level modules, usually the simplest ones. As the development progresses to top-level modules, they are integrated and tested along with the already-tested lower-level modules.
Advantages:
- Easier to localize the fault. If testing reveals an error, it's easier to isolate because the most likely cause is a lower-level module that has already undergone testing.
- Saves time. Testing can start earlier because there's no need to wait until all modules are developed.
Disadvantages:
- Critical modules are tested last. This can result in critical bugs being discovered too late, making their fixes more difficult and time-consuming.
- Failure to create an early prototype. This approach necessitates testing all lower-level modules before testing the upper-level modules, which makes it impossible to create an early prototype of the system for demonstrating or testing requirements
Additional nuances:
- Bottom-up integration testing can be effective for systems consisting of many modules or modules with complex interfaces.
- This approach can benefit systems that need to be tested for security compliance.
Conclusion
Bottom-up integration testing is a practical testing approach that can help improve software quality. However, it is essential to consider its disadvantages in order to minimize the risks.
Top-down integration testing
Top-down integration testing is an approach in which system modules are integrated and tested according to their dependencies. This approach begins with testing the top-level modules, which are usually the most complex and critical to the system's operation. At the beginning, top-level modules are tested together with mock data. As lower-level modules are developed, they are integrated with upper-level modules that have already been tested and tested together.
Advantages:
- Fault localization is easier. If an error is found during testing, it is easier to isolate because it is most likely caused by a top-level module that has already been tested.
- Opportunity to get an early prototype. This approach allows you to start testing earlier since you do not have to wait until all the modules are developed.
- Critical modules are tested as a priority. This can help identify and fix critical bugs early in development when fixes are more readily available.
Disadvantages:
- Requires many connectors. Mocks are needed to test top-level modules that depend on lower-level modules that still need to be ready but can make testing more difficult and ineffective.
- Lower-level modules need to be tested adequately. They may be incompletely or incorrectly tested because they are only tested as part of the higher-level modules.
Additional nuances:
- Top-down integration testing can be effective for systems with a few modules or simple interfaces.
- This approach can benefit systems that need to be tested for security compliance.
- This is a good approach to how to do integration testing in microservices due to the ability to use mock data to test microservice interfaces.
Conclusion
Top-down integration testing is a practical testing approach that can help improve software quality. However, it is important to consider its disadvantages in order to minimize the risks.
Sandwich testing
Sandwich testing is an integration testing approach that combines top-down and bottom-up testing elements. This approach starts by testing the top-level modules with stubs representing the lower-level modules that are not yet ready. The lower-level modules are then integrated with the upper-level modules and tested as a system.
Advantages:
- Fault localization is easier. If a fault is found during testing, it is easier to localize because it is likely to be caused by a top-level module or a lower-level module that has already been tested.
- Time- savings. Testing can start earlier because you don't have to wait until all modules are developed.
- Critical modules are tested in priority order. This can help identify and fix critical bugs early in development when fixing them is easier.
Disadvantages:
- More stubs and drivers are required.
- Lower-level modules may not be tested adequately.
Additional nuances:
- Sandwich testing can be effective for systems that consist of many modules or modules with complex interfaces.
- This approach can be particularly useful for systems that need to be tested for security compliance.
- This is a good approach to conducting integration testing of platforms due to the ability to test the top-level modules of the platform before completing the development of the lower-level modules and further testing the lower-level modules before integrating them into the platform.
Conclusion
Sandwich testing is an effective approach to integration testing that can help improve software quality. This approach combines the advantages of both top-down and bottom-up approaches, making it more effective and flexible than each separately.
How to perform integration testing: main stages
Determine an integration testing strategy that fits your development principles. Decide the best testing approach for your project: top-level, bottom-up, Big Bang, or sandwich.
Examine your application architecture and identify critical modules. These modules should be tested first, as they impact the entire application the most.
When you receive interface designs from the development team, create test cases to validate all interfaces in detail. Test interfaces with database, external hardware, or other software in detail.
Prepare test data in advance. Do not select test data while the test cases are running. This will help avoid errors and omissions during the testing process.
Create test scenarios that fully cover all the functionalities of the application. Pay attention to boundary values and non-standard scenarios while using the application.
Once you write tests, the next step involves understanding how to perform integration testing in a specific environment.
When testing, use automation testing tools. This will reduce testing time and increase the accuracy of the results.
After running the tests, analyze the results and track the errors found. Fix the bugs and restart the tests to ensure they are fixed.
Don't forget to update the test cases when the application changes. Regularly updating test cases will help ensure the application runs correctly and without errors.
Select the longest positive path for the integration test that tests interactions with all out-of-process dependencies. If no single path passes through all such interactions, write additional integration tests. Generate as many as needed to cover interactions with each external system. These are the main stages of integration testing, following which you can identify errors associated with the interaction between software modules and improve their quality.
Entry and exit criteria for integration tests
The entry and exit criteria for integration tests define the starting point and completion conditions for integration tests.
Entry Criteria
- The integration test plan document has been approved
- Integration test cases are fully prepared
- Test data has been created
- Critical and high-priority defects have been resolved
- The test environment is ready for integration
Exit Criteria
- All integration tests have been completed
- All critical and high-priority defects have been closed
- Test report prepared
Tools for integration testing
The choice of integration testing tools can vary based on the technology stack, programming languages, and frameworks used in a particular project. Here are some commonly used integration testing tools:
Cypress: It has functionality that allows you to test individual modules and the interaction between them
Mocha: This powerful JavaScript testing framework allows you to create stable and efficient tests for the interaction of application components.
JUnit: A popular testing framework for Java applications, JUnit is widely used for integration testing. It annotates test methods, assertions for testing expected results, and test runners for executing tests.
Postman: While traditionally known for API testing, Postman can also be used for integration testing by creating and managing collections of API requests and automating the execution of these requests to simulate various scenarios.
SoapUI: A tool specifically designed for testing REST APIs and SOAP, SoapUI facilitates the creation of comprehensive and complex integration tests. It supports data-driven testing, assertions, and reporting.
Supertest: A JavaScript library used for testing HTTP that provides an expressive API for making HTTP requests allows for the simulation and testing of interactions with web APIs.
Selenium WebDriver: Often associated with functional testing of web applications, Selenium WebDriver can also be utilized for integration testing. It allows the automation of browser interactions and can be integrated into various testing frameworks.
Cucumber: A behavior-driven development (BDD) tool that supports writing specifications in natural language. Cucumber is often used for integration testing to promote collaboration between developers and non-technical stakeholders.
WireMock: A flexible library used for mocking web services and stubbing. WireMock is often used to create simulated HTTP responses, allowing testing of interactions between different system components.
Citrus Framework: A framework for integration testing of message-based interactions, Citrus supports various messaging protocols (e.g., JMS, HTTP, SOAP) and enables end-to-end testing of message-driven systems.
How to do Integration Testing in Java?
To conduct integration testing in Java, focus on validating the collaboration between different Java components or modules. Employ testing frameworks like JUnit or TestNG to design and execute test cases, ensuring seamless integration of Java code.
How to Make Integration Testing in Python?
For integration testing in Python, utilize frameworks like pytest or unit test. Design test scenarios that assess the interaction and collaboration between various Python modules or components, ensuring the robustness and cohesion of your Python-based system.
Choosing the integration testing tools based on your project's requirements and technologies is essential. Additionally, the integration testing strategy may involve a combination of these tools to cover various aspects of integration between system components.
Final thoughts on how to do integration testing
Software testing acts as one of the main stages of the development cycle. Within this process, integration testing is one of the most significant links. Thorough understanding of how to perform system integration testing in complex environments guarantees that all components interact seamlessly.
Integration testing, integrated into the project, ensures that the product fulfills functional requirements and works as expected. It allows you to identify critical defects early in development before bug fixes become more complex and costly. Identifying and fixing compatibility, data flow, and interoperability issues between components improves software quality.
Integration testing boosts confidence in the product by verifying that the entire system works as a whole and provides users with the stated functionality. In general, integration testing ensures that you deliver high-quality and stable software solutions to the market.
Comments
There are no comments yet. Be the first one to share your opinion!
Was this article helpful to you?
Looking for reliable Software Testing company?
Let's make a quality product! Tell us about your project, and we will prepare an individual solution.
FAQ
How do you write an integration test plan?
An integration test plan outlines the scope, objectives, resources, and schedule for integration testing. It should identify the modules to be tested, the tests to be performed, the tools to use, and the success criteria.
What are integration test scenarios?
Integration test scenarios describe specific interactions between software modules that will be tested. They should be based on user requirements and use cases and cover a wide range of possible scenarios.
Is selenium an integration test?
Selenium is a tool for test automation for web applications. It can be used to perform integration testing by simulating user interactions and verifying the results.
Is integration testing done by QA or the developer?
Both QA testers and developers can be involved in integration testing. QA testers typically focus on designing and executing test cases, while developers may be responsible for writing test code and fixing bugs.
Is integration testing manual or automation?
Integration testing can be done manually or through automation. Automation can save time and improve test coverage, but developing and maintaining test scripts requires additional effort.