In the field of software testing, the term stubs and drivers refers to the replica of the modules, which acts as a substitute, to the under developed or missing module.
The stubs and drives are specifically developed, to meet the necessary requirements of the unavailable modules.
Consider an example of a web application, which consists of 4 modules i.e., Module-A, Module-B, Module-C and Module-D. Each of the following modules is responsible for some specific activity or functionality, as under
Module-A ? Login page of the web application
Module-B → Home page of the web application
Module-C → Print Setup
Module-D → Log out page
The modules A, B, C & D involves the interdependencies of each module over other.
It is always preferable, to perform testing, in parallel, to the development process. Thus, it implies that subsequent testing must be carried out, immediately after the development of the each module.
Module-A, will be tested, as soon as, it develops. However, to carry out and validate the testing procedures in respect of module-A, there urges the need of module-B, which is not yet developed. The expected functionality of the login page (module-A) could be validated, only if it is directed to the home page (module-B), based on the valid and correct inputs.
But, on the non-availability of the module-B, it will not be possible to test module-A. These types of circumstances, introduces the stubs & drivers in the process of software testing. A dummy module, representing the basic functionality or feature of the module-B, is being developed, and thereafter, it is being integrated with the module-A, to perform testing, efficiently.
Similarly, stubs and drivers, are used to fulfil the requirements of other modules, such as
Log out page (Module-D), needs to be directed to the login page (Module-A), after successfully logging out from the application. In the event of unavailability of Module-A, stubs and drivers will work as a substitute for it, in order to carry out the testing of module-D.
Yes, basically the features and purpose of stubs and drivers are same. Both of them work as a substitute for the missing or unavailable module. However, the difference between them can be visualized during the integration testing.
Stubs are commonly referred to as "called programs" and are being used in top bottom approach of the integration testing, whereas drivers are "calling program" and they are used in bottom-up integration testing.
Stubs are similar to the components, which are under test, in a very simple and basic form, whereas driver is used to invoke the component that needs to be tested.
Stubs, are usually, considered for low level modules, whereas drivers represents the high level modules.