What is the difference between stubs and drivers in software testing?

What is the difference between stubs and drivers in software testing? by @r_ydv

Answer by Rahul Yadav:

Stubs and Drivers are two types of test harness. Test harness are the collection of software and test data which is configured so that we can test a program unit by simulating different set of conditions, while monitoring the behavior and outputs.

Stubs and drivers both are dummy modules and are only created for test purposes.

Stubs are used in top down testing approach, when you have the major module ready to test, but the sub modules are still not ready yet. So in a simple language stubs are "called" programs, which are called in to test the major module's functionality.

For eg. suppose you have three different modules : Login, Home, User. Suppose login module is ready for test, but the two minor modules Home and User, which are called by Login module are not ready yet for testing.
At this time, we write a piece of dummy code, which simulates the called methods of Home and User. These dummy pieces of code are the stubs.

On the other hand, Drivers are the ones, which are the "calling" programs. Drivers are used in bottom up testing approach. Drivers are dummy code, which is used when the sub modules are ready but the main module is still not ready.

Taking the same example as above.Suppose this time, the User and Home modules are ready, but the Login module is not ready to test. Now since Home and User return values from Login module, so we write a dummy piece of code, which simulates the Login module. This dummy code is then called Driver.

Here is a link which explains this using block diagrams : Difference between stub and driver

What is the difference between stubs and drivers in software testing?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s