software test stubs

Test Stubs and Test Drivers

Posted on


What are software test stubs?
– Software test stubs are programs which simulate the behaviors of software components (or modules) that are the dependent modules of a under test module. Stubs are the dummy routines which are introduced that simulate a module. It is used in the top-down approach of the testing in which testing is done from the top of hierarchy. Stubs simulate the low level modules.

What are software test drivers?
– Software test drivers are programs which simulate the behaviors of software components (or modules) that are the control modules of a under test module. Drivers are the dummy routines which are introduced that invoke a module. It is used in the bottom-up approach of the testing in which testing is done from the bottom of hierarchy. Drivers simulate the high level modules.

Integration testing in a variety of ways:

  • The bottom-up approach requires the lowest-level units be tested and integrated first. These units are frequently referred to as utility modules. By using this approach, utility modules are tested early in the development process and the need for stubs is minimized. The downside, however, is that the need for drivers complicates test management and high-level logic and data flow are tested late. Like the top-down approach, the bottom-up approach also provides poor support for early release of limited functionality.
  • The top-down approach to integration testing requires the highest-level modules be test and integrated first. This allows high-level logic and data flow to be tested early in the process and it tends to minimize the need for drivers. However, the need for stubs complicates test management and low-level utilities are tested relatively late in the development cycle. Another disadvantage of top-down integration testing is its poor support for early release of limited functionality.

For example (STUB):
We have Modules A,B,C.  A module is ready and Need to Test it , But it calls functions from B and C (Which is not ready). To test at a particular module we write a Small Dummy piece of code which Simulates B and C which will return values for A, These piece of Dummy code is Called Stubs in a Top Down Integration.

For example (DRIVER):
We have Modules A,B,C. B and C modules ready Need to Test it, but A module is not ready (Which return values from A) So to get the values from A We write a Small Piece of Dummy code for A which returns values for B and C, So these piece of code is called Drivers in Bottom Up Integration.