Stubs are used during Top-down integration testing, in order to simulate the behaviour of the lower-level modules that are not yet integrated. Stubs are the modules that act as temporary replacement for a called module and give the same output as that of the actual product.
Stubs are also used when the software needs to interact with an external system.
The above diagram clearly states that Modules 1, 2 and 3 are available for integration, whereas, below modules are still under development that cannot be integrated at this point of time. Hence, Stubs are used to test the modules. The order of Integration will be:
1,2 1,3 2,Stub 1 2,Stub 2 3,Stub 3 3,Stub 4
+ Firstly, the integration between the modules 1,2 and 3 + Test the integration between the module 2 and stub 1,stub 2 + Test the integration between the module 3 and stub 3,stub 4