Software testing is a procedure to test software fitment as per requirement. To understand integration testing on stubs, we need to get clear about what a stub is first of all.
A stub is a piece of code that is used for other programming functionality.
It is used in top-down integration testing. It is used to simulate the behavior of lower-level modules that are not integrated yet.
As shown in the above diagram, modules 1, 2, and 3 are available for integration, whereas stub 1, stub 2, stub 3, and stub 4 are not ready yet for integration. In such a situation, a stub is used to test modules.
As shown in the above diagram, it is following a top-down approach to develop and test. So the answer to this question is ‘Top-Down’ integration uses Stub for testing.
Top-Down integration Testing starts by testing higher-level modules, and phase by phase it covers lower-level modules.
Example :
We need to develop a web application with layered architecture.
There are 3 layers that need to be developed and tested in a layered architecture.
1. UI Layer
2. Service Layer:
3. Data Access Layer:
1. Start testing with the UI layer:
The UI layer is tested first, then it will get integrated with the service layer.
And we need to create a stub that simulates the behaviour of the data access layer.
2. Testing using stub:
If the data access layer is not implemented yet, we can use stub to simulate the access layer.
So to conclude, stub is used in top-down integration Testing process.
Priyanka Kanthariya