top down approach and bottom up approach in testing code example

Example 1: top down vs bottom up testing

Top-Down testing begins with the system and 
works its way down to the unit level.
• Bottom-up testing checks in the opposite
direction, unit level to interface to
overall system. Both have value but
bottom-up testing usually aids in discovering
defects earlier in the development cycle, 
when the cost to fix errors is lower.

Example 2: top to down approach testing

Testing takes place from top to bottom. 
High-level modules are tested first and
then low-level modules and finally 
integrating the low-level modules to
a high level to ensure the system is
working as intended. Stubs are used as
a temporary module if a module is 
not ready for integration testing.

Tags:

Misc Example