Stubs and Drivers




Stubs and Drivers

The concept of Stubs and Drivers are mostly used in the case of component testing. Component testing may be done in isolation with the rest of the system depending upon the context of the development cycle.

Stubs and drivers are used to replace the missing software and simulate the interface between the software components in a simple manner.

Suppose you have a function (Function A) that calculates the total marks obtained by a student in a particular academic year. Suppose this function derives its values from another function (Function b) which calculates the marks obtained in a particular subject.

You have finished working on Function A and wants to test it. But the problem you face here is that you can't seem to run the Function A without input from Function B; Function B is still under development. In this case, you create a dummy function to act in place of Function B to test your function. This dummy function gets called by another function. Such a dummy is called a Stub.

To understand what a driver is, suppose you have finished Function B and is waiting for Function A to be developed. In this case you create a dummy to call the Function B. This dummy is called the driver.


Component testingStub: A stub is called from the software component to be tested. As shown in the diagram above ‘Stub’ is called by ‘component A’.
Driver: A driver calls the component to be tested. As shown in the diagram ‘component B’ is called by the ‘Driver’.

 
 
The difference between stubs and driver can be shown as:
 
Stubs
  1. Used in Top down approach
  2. Top most module is tested first
  3. Stimulates the lower level of components
  4. Dummy program of lower level components
Driver
  1. Used in Bottom up approach
  2. Lowest modules are tested first.
  3. Stimulates the higher level of components
  4. Dummy program for Higher level component

Comments

Popular posts from this blog

EAT THE FROG