Top-down testing technique is an incremental approach. In top-down testing technique, high-level modules are integrated and tested first. Testing then continues hierarchically to the bottom level with the help of stubs. When a module is tested, the modules it invokes are represented by stubs, which return control back to the calling module with a replicated result. As testing steps forward down the program structure, each stub is replaced by the actual code it represents.
1. We test a system by starting with top level module and stubs for all the modules which the top level module invokes. We do not go forward until all the errors are removed.
2. Pick up any actual module invoked by top level module (as a stub) in step 1. Now replace the stub of the module you picked with the actual module. Also add stubs for the modules which this new module calls. Run this new system.
3. Decide the next module to test (this can be a module called by top level module or the module in step 2).
4. In this way we have to continue incrementally adding and testing modules until end module.
Advantages of Top-Down testing
- Top-Down testing works well with top down development.
- This is advantageous if most important errors occur toward the top of the program.
Disadvantages of Top-Down testing
- Designing multiple stubs may be a time consuming process.
Also See:
Bottom-Up Testing
Testing Stubs & Drivers
Integration Testing