Open In App

Difference between Stubs and Drivers

Improve
Improve
Like Article
Like
Save
Share
Report

Prerequisite : Software Engineering | Integration Testing 

There are many primary elements that are required to make the product testing lucid hassle-free. Every element has its own specific utility that helps a lot while software testing and delivering the expected functionality as per the SRS document as much as possible. Stubs and Drivers are two such elements that play a very crucial role while testing; they replace the modules that haven’t been developed yet but are still needed in the testing of other modules against expected functionality and features. 

Stubs and Drivers : 
The Stubs and Drivers are considered as elements which are equivalent to to-do modules that could be replaced if modules are in their developing stage, missing or not developed yet, so that necessity of such modules could be met. Drivers and stubs simulate features and functionalities, and have ability to serve features that a module can provide. This reduces useless delay in testing and makes the testing process faster. 

Stubs are mainly used in Top-Down integration testing while the Drivers are used in Bottom-up integration testing, thus increasing the efficiency of testing process. 

1. Stubs : 
Stubs are developed by software developers to use them in place of modules, if the respective modules aren’t developed, missing in developing stage, or are unavailable currently while Top-down testing of modules. A Stub simulates module which has all the capabilities of the unavailable module. Stubs are used when the lower-level modules are needed but are unavailable currently. 

Stubs are divided into four basic categories based on what they do : 

  • Shows the traced messages,
  • Shows the displayed message if any,
  • Returns the corresponding values that are utilized by modules,
  • Returns the value of the chosen parameters(arguments) that were used by the testing modules.

2. Drivers : 
Drivers serve the same purpose as stubs, but drivers are used in Bottom-up integration testing and are also more complex than stubs. Drivers are also used when some modules are missing and unavailable at time of testing of a specific module because of some unavoidable reasons, to act in absence of required module. Drivers are used when high-level modules are missing and can also be used when lower-level modules are missing. 

Ex : Suppose, you are told to test a website whose corresponding primary modules are, where each of them is interdependent on each other, as follows: 

  • Module-A : Login page website, 
  • Module-B : Home page of the website 
  • Module-C : Profile setting 
  • Module-D : Sign-out page

It’s always considered good practice to begin development of all modules parallelly because as soon as each gets developed they can be integrated and could be tested further as per their corresponding interdependencies order with a module. But in some cases, if any one of them is in developing stage or not available in the testing process of a specific module, stubs or drivers could be used instead. 

Assume Module-A is developed. As soon as it’s developed, it undergoes testing, but it requires Module-B, which isn’t developed yet. So in this case, we can use the Stubs or Drivers that simulate all features and functionality that might be shown by actual Module-B. So, we can conclude that Stubs and drivers are used to fulfill the necessity of unavailable modules. Similarly, we may also use Stubs or Drivers in place of Module-C and Module-D if they are too not available. 

Do both drivers and Stubs serve the same functionality? 
Yes, we can say both serve the same feature and are used in the absence of a module(M1) that has interdependencies with an other module(M2) that is need to be test, so we use drivers or stubs in order to fulfill module(M1)’s unavailability’s and to serve its functionality. 

Difference between Stubs and Drivers : 

S.No. Stubs Drivers
1. Stubs are used in Top-Down Integration Testing. Drivers are used in Bottom-Up Integration Testing.
2. Stubs are basically known as a “called programs” and are used in the Top-down integration testing. While, drivers are the “calling program” and are used in bottom-up integration testing.
3. Stubs are similar to the modules of the software, that are under development process. While drivers are used to invoking the component that needs to be tested.
4. Stubs are basically used in the unavailability of low-level modules. While drivers are mainly used in place of high-level modules and in some situation as well as for low-level modules.
5. Stubs are taken into use to test the feature and functionality of the modules. Whereas the drivers are used if the main module of the software isn’t developed for testing.
6. The stubs are taken into concern if testing of upper-levels of the modules are done and the lower-levels of the modules are under developing process. The drivers are taken into concern if testing of lower-levels of the modules are done and the upper-levels of the modules are under developing process.
7. Stubs are used when lower-level of modules are missing or in a partially developed phase, and we want to test the main module. Drivers are used when higher-level of modules are missing or in a partially developed phase, and we want to test the lower(sub)- module.

Last Updated : 25 Apr, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads