Sunday 19 June 2016

What is Stubs & Drivers? Why We Use Stubs And Drivers? Describe with an example.

stubs & drivers

What is Stubs and Drivers. Why do we use them?
Stubs:- Stubs are simply a dummy modules, that are always recognize as "called program" or in simple, stubs are used in integration testing (top-down approach).
Stubs are generally used when sub programs are under construction.
Example:- Let us take an example of an application, where we have 3 modules ie. Login, Home and user modules. Now Login module is ready and need to go under test, so for that we need to call functions from home and user (which are not completed). Therefore, to test those modules or functions we need to write a short dummy piece of code for home and user. So that it simulates home and user, which will return any values for Login. This short dummy piece of code is called Stubs.

Drivers:- Drivers are also considered as dummy modules, that are distinguish as "calling program" that is used in bottom up integration testing.
Drivers are only used when main program are under construction.
Example:- Considering the same Example as above: When we have Home and User modules get ready and Login module is not, and we need to test Home and User modules, which return values from Login module, So to extract the values from Login module, we write a Short Piece of Dummy code for login which returns value for home and user, So these pieces of code is always called Drivers.

5 comments: