The fundamental rule for testing functions requires that every function be tested in an already fully tested and debugged program. How can this be accomplished?
a. Impossible! The main function must have all the functions it calls attached to get it to compile and run properly.
b. The main function is tested with stub functions replacing each` function.
c. Write drivers for the stub functions to test them.
d. Add each non-stub function in turn for testing.
e. Write drivers for the function implementations one at a time to test them independently.
b) d) and e) are correct.
Explanation: a) is unreasonably pessimistic. The stubs in b) should be short enough that their correctness may reasonably assumed, hence c) is unreasonable, if possible. In d) we add just one function at a time, and may need to change other stubs to vary data passed to successive functions. If inconvenient to have a main program to drive the function, a driver that provides typical data to a call is an alternative.