Learning Resources for Software Engineering Students »
Author(s): Jacob Li PengCheng
Integration testing is a part of software testing where individual parts of your application are combined and tested as a group. This usually happens after the
Let's look at an example to better understand what these means. Suppose that you have built an online food ordering system and the architecture diagram of your application is shown as follows:
Zooming in on the food ordering aspect of this system, a unit test on the
Order Summary checks for the correctness of the order details recorded and a unit test on the
Order Food checks that the food ordered is in the correct format.
After completion of unit testing on individual modules, an integration test on
Order Food and
Order Summary checks that upon ordering food, the order summary reflects the correct food orders.
After completion of integration testing, a system test on the entire application could mimic a customer's point of view and checks that the functionalities such as
Generate Report work as intended.
In a software application, each software module is usually designed and unit tested by different programmers. Since these programmers may work in isolation and have different understandings of the software requirements, integration testing is necessary to ensure that the software modules work in unity and expose any faults in the interaction between different units.
Order Food module mentioned earlier allows each user to submit up to 10 orders each time. If the
Order Summary module can only record a maximum of 5 orders each time, when the orders from
Order Food are passed to the
Order Summary module, 5 of the orders may not be taken into account.
Hence, there is potential for problems such as such as data loss, inaccurate results and even system errors.
Integration tests find these discrepancies before any serious damage is done.
Although system testing also help to uncover faults between modules, integration testing is still preferable as it is able to better isolate the scope of the features during testing, making it easier and faster to test. In fact, many integration problems can be detected and resolved in the early stage of development, which makes debugging easier when problems arise in the future.
Hence, integration testing can be useful in the development of any non-trivial software product. Concepts shared in this article can be adopted by different software applications.
On top of that, in the current era of
This article showcases more advantages of doing integration testing before system testing.
This article provides more information on instances where integration testing is important.
Using this specific system as an example, below is a list of things you should follow to execute effective integration testing:
Before the actual implementation of your integration tests, it is important to decide on the approach used. There are a few different approaches of integration testing in which you can adopt depending on the development progress of your application.
This approach involves integrating all the modules in your design diagram together and testing everything at once in a complete state. This is convenient but it is difficult to isolate defects and there is a high chance of missing critical underlying defects. Big bang integration testing is usually used for smaller applications with few modules.
An example of how big bang integration testing can be applied to our given example is shown below:
This article provides more details on the big bang approach.
This approach involves integrating two or more logically related modules. The other related modules are added and tested for proper functioning. This is repeated until all the modules are joined (or integrated incrementally) and tested successfully. It is usually preferred for applications with many modules.
Incremental integration testing is further split into the 3 approaches shown below:
|Top-down approach||Bottom-up approach||Hybrid / sandwich approach|
|Description||Based on the dependency order of modules, high level modules are tested first, followed by lower level modules.||The reverse of top-down approach.||A mix of both top-down bottom-up approaches.|
|Advantages||Early discovery of high level architecture / design defects.||Easier to create test cases bottom up.||Beneficial for big project to distribute tasks on testing.|
|Main control points of the system are tested early.||Critical modules on functionalities are tested first.||Allow top-down and bottom-up approach to run side by side.|
|Disadvantages||Significant low level modules are tested late in the cycle.||There is no testable working system until the higher level modules are build.||It is difficult to test for highly interconnected modules.|
||Higher cost from using both driver and stub. You can better understand the difference here.|
This article provides a more detailed guide, with examples, on using specific methods for incremental testing together.
The NUS Software Engineering textbook also offers some concrete examples of different approaches of integration testing.
Before the actual coding is done, a basic test strategy deciding the test cases and test data used should be crafted. This usually involves setting a test case ID, objective, description and expected result.
Using the example shown above, below shows a sample integration test used for the
Test case ID: 1 Objective: Check the link between login and ordering modules Description: Enter login credentials and click on login button Expected result: To be directed to order food page based on the login user
This article explains more about the ways to structure incremental testing.
Depending on the approach you have chosen for your integration plan and the test cases, the way you execute your code for testing will differ.
Big bang approach usually requires all the modules to be developed before you can start with the integration testing.
Incremental approach is usually conducted simultaneously with the module's development. Stubs and drivers are used to mimic the modules for writing tests since not all modules are developed at the point of integration testing. The NUS Software Engineering module site provides concrete codes for using stubs.
Either way, such test scripts can help you in singling out specific integration errors to be resolved before it gets more serious. Hence, you should ensure that all high prioritized bugs are fixed before moving on.
This article shows more details on how to set up a test environment for better integration testing.
In the event of failing your integration test case, it is important to learn how to track down the
This article covers more details on how to effectively track down defects in a system and fix them.
Make sure that each module is unit tested before integration testing
By ensuring that each unit test is completed properly, integration testing will be smoother as we can focus mainly on the flow of data between modules.
Prioritize the modules to be tested
Despite the need to cover all areas of integration of the application, it is important to ensure that critical modules needs to be tested first.
Keep testing suites separate
Integration tests should be run separately from unit tests. Developers working on backend logic can run unit tests frequently and get immediate result. They do not have to meddle with integration testing unnecessarily.
Ensure that all executed test cases are documented
This helps you to identify errors quickly through an integration test. It also helps to standardize the way integration testing is carried out in your application so that everyone can conform to the given standard.
Automate your tests (optional)
As far as possible, automate all your tests, especially when you use the incremental approach since regression testing is important each time you integrate a new unit, and manual regression testing can be inefficient. You can find a list of most commonly used automation tools for integration testing. This article provides more useful tips for CI projects.
The article Dos and donts of integration testing has further advices on specific details to take note when writing your own integration test.
Generally integration test can be implemented based on your existing unit testing tools. However, if you do not have an existing testing tool in place, here are some useful tools that you can consider for your integration testing:
VectorCast is a tool which operates based on executing unit tests first before integration tests as discussed in this article.
Gauge acts as a plugin which can be incorporated to any language or IDE. It is an lightweight cross-platform test automation tool which makes testing easier to maintain, more readable and scalable.
Selenium is an open source test automation framework focusing on web applications. It supports a wide range of programming languages, cross-browser testing with extensive libraries and the ability to create robust test scripts to handle many scenarios. The article Getting started with Selenium for automated website testing gives an overall guide to integrating selenium to automate integration testing for your web application.
Google EarlGrey is a native iOS automation test framework allowing developers to write and maintain clear concise tests. It has a powerful built-in synchornization which allows it to reproduce any UI interactivity and test them.
Although there are many integration testing tools available, more research needs to be conducted to ensure the compatibility of the tools with your application. This article has more integration testing tools.