Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Stub Testing and Driver Testing

17,343 views

Published on

Short introduction to stub testing and driver testing.

Published in: Technology, Business

Stub Testing and Driver Testing

  1. 1. Stubs and DriversTesting Powerpoint Templates Page 1
  2. 2. What are STUBS and DRIVERS?Stubs and Drivers are used inintegration testing for TOP-DOWN and BOTTOM-UPtesting respectively Powerpoint Templates Page 2
  3. 3. What is Top-Down Development?Top-Down development: We first create the“root” module and after that each module(child) that is called by the “root”. Next wemove down the tree and consider each childas a root for the next modules that need to bedeveloped. We repeat these steps until wereach the “leaf” modules Powerpoint Templates Page 3
  4. 4. What is Bottom-Up Development?Bottom-Up development: Considering thesame tree of modules described in theprevious screen, we first develop the leafmodules. Next, we move up one level anddevelop the parent-modules (the ones that callthe leaf modules). After each level is complete,we move up one level and develop it, until wereach the “root” module. Powerpoint Templates Page 4
  5. 5. Context –A Normal Program Main Main point of entry Powerpoint Templates Page 5
  6. 6. Context –A Normal Program Main Main point of entry FunctionsFunction 1 Function 2 Function 3 called in main() Powerpoint Templates Page 6
  7. 7. Context –A Normal Program Main Main point of entry FunctionsFunction 1 Function 2 Function 3 called in main() Last layer function function function of functions Powerpoint Templates Page 7
  8. 8. Context – No circular dependencies Main Main point of entry FunctionsFunction 1 Function 2 Function 3 called in main() Last layer function function function of functions Powerpoint Templates Page 8
  9. 9. Context – Modules, not Functions Main Main point of entry Modules Module 1 Module 2 Module 3 called in main() Last layerModule L Module K Module F of Modules Powerpoint Templates Page 9
  10. 10. A Tipical Example Module L Module K Module F (not developed) (not developed) Powerpoint Templates Page 10
  11. 11. A Tipical Example So how can we test MODULE L? Module L Module K Module F (not developed) (not developed) Powerpoint Templates Page 11
  12. 12. A Tipical Example Module L Module K Stub Module F Stub Dummy code that SIMULATES the functionality of the undeveloped modules Powerpoint Templates Page 12
  13. 13. Code Example - Stubvoid functionWeTest(params..) { ………... int p = price(param1); ………..}void price(int param) { //this is the stub return 10; // We don’t care what the price is. We justneed a value so we can test the other function} Powerpoint Templates Page 13
  14. 14. Let’s Move to Drivers (not developed) Module L Module K Module F Powerpoint Templates Page 14
  15. 15. Let’s Move to Drivers Dummy code that returns values from Module L and Module K Module L Driver Module K Module F Powerpoint Templates Page 15
  16. 16. A Tipical Examplevoid functionThatCallsPrice (params..) { //this is the driver int p = price(param1); printf(“Price is: %d”, p);}void price(int param) { //complex ecuations and DB interogations thatdetermin the real price} Powerpoint Templates Page 16
  17. 17. ConclusionsNo need to write all the modules in order to begintestingStubs and Drivers are usually easy to createThe hard part is identifying what is essential and whatcan be simulatedStubs and Drivers can be thrown away once theequivalent module is created Powerpoint Templates Page 17

×