For any software application, both Unit testing and Integration testing are very important as they each employ unique processes to test the software application. But one or both of them cannot replace Functional testing.
In this article, we will understand Unit, Integration, and Functional testing and clarify the differences between these forms/levels of testing.
For absolute newcomers, let us understand these three types of testing with an oversimplified example: For a functional mobile phone, the main parts required are “battery” and “sim card”.
Now that we have seen the example in layman’s terms, let us now take a technical example, the login page:
Almost every web application requires its users/customers to log in. For that, every web application has to have a “Login” page that has these elements:
For unit testing, the following may be the test cases:
For integration testing, the following may be the test cases:
Now, after unit and integration testing are done, let us see the additional test cases that are considered for functional testing:
There are much more such cases which come to the mind of a functional tester while performing functional testing. But a developer cannot take up all cases while building Unit and Integration test cases.
Thus, there are plenty of scenarios yet to be tested even after unit and integration testing.
It is now time to examine unit, integration and functional testing one by one.
What You Will Learn:
As the name suggests, this level involves testing of a ‘Unit’. Here unit can be the smallest part of the application that is testable; be it a smallest individual function, method, etc.
Software developers are the ones who write the unit test cases. The aim here is to match the requirements and the unit’s expected behavior.
Below are few important points about unit testing and its benefits:
JUnit (Java framework), PHPUnit (PHP framework), NUnit (.Net framework) etc. are popular unit testing tools used for different languages.
Integration testing is testing the integration of different part of the system together. Two different parts or modules of the system are first integrated and then integration testing is performed.
The aim of integration testing is to check functionality, reliability, and performance of the system when integrated.
Integration testing is performed on the modules that are unit tested first and then integration testing defines whether the combination of modules gives desired output or not.
Integration testing can either be done by independent testers or by developers too.
There are 3 different types of Integration testing approaches. Let us discuss each one of them briefly:
a) Big Bang Integration approach:
In this approach, all the modules or units are integrated and tested as a whole at one time. This is usually done when the entire system is ready for integration testing at a single point in time.
Please do not confuse this approach of integration testing with system testing; only integration of modules or units is tested and not the whole system as is done in system testing.
The big bang approach’s major advantage is that everything integrated is tested at one time.One major disadvantage is that it becomes difficult to identify the failures.
Example: In the figure below, Unit 1 to Unit 6 are integrated and tested using the Big bang approach.
b) Top down approach:
Integration of the units/modules is tested from top to bottom levels step by step.
The first unit is tested individually by writing test STUBS. After this, the lower levels are integrated one by one until the last level is put together and tested.
Top down approach is a very organic way of integrating as it is consistent with how things happen in the real environment.
The only concern with this approach is that the major functionality is tested at the end.
c) Bottom Up approach:
Units/modules are tested from bottom to top level, step by step, until all levels of units/modules are integrated and tested as one unit.
Stimulator programs called DRIVERS are used in this approach. It is easier to detect issues or errors at the lower levels.
The major disadvantage of this approach is that the higher level issues can only be identified at the end when all the units have been integrated.
A black box testing technique, where the functionality of the application is tested to generate desired output on providing certain input is called ‘Functional testing’.
In our software testing processes, we do this by writing test cases as per the requirements and scenarios. For any functionality, the number of test cases written can vary from one to many.
Test cases basically comprise of the following parts:
“Requirement-Based” and “Business scenario based” are the two forms of functional testing that are carried out.
In Requirement based testing, test cases are created as per the requirement and tested accordingly.In Business scenario based functional testing, testing is performed keeping in mind all the scenarios from a business perspective.
However, the major disadvantage of functional testing is the probable redundancy in testing and the possibility of missing some logical errors.
Now that we have a brief idea of Unit, Integration, and Functional testing, let’s look at their differences.
Here are some of the major ones:
|Unit testing||Integration testing||Functional testing|
|Definition and purpose||Testing smallest units or modules individually.||Testing integration of two or more units/modules combined together for performing tasks.||Testing the behaviour of the application as per the requirement.|
|Complexity||Not at all complex as it includes smallest codes.||Slightly more complex than unit tests.||More complex compared to unit and integration tests.|
|Testing techniques||White box testing technique.||White box and black box testing technique. Grey box testing||Black box testing technique.|
|Major attention||Individual modules or units.||Integration of modules or units.||Entire application functionality.|
|Error/Issues covered||Unit tests find issues that can occur frequently in modules.||Integration tests find issues that can occur while integrating different modules.||Functional tests find issues that do not allow an application to perform its functionality. This includes some scenario based issues too.|
|Issue escape||No chance of issue escape.||Less chance of issue escape.||More chances of issue escape as the list of tests to run is always infinite.|
The unit, Integration, and Functional testing: All three of them are correlated. To attain full coverage it is required to have unit tests for the paths/lines of code, functional and Integration tests for assurance that the ‘units’ work together cohesively.
Hope this article has given you a clear idea about Unit, Integration and functional testing and their differences, although there is much more to these forms of testing.
About the author: This is a guest post by Sushma S. She is having 4+ years of software testing experience and currently working as a Senior Software Test Engineer
Feel free to write your comments and/or thought below :)