5.3. Top-down versus Bottom-up Testing

Given the conclusion of the previous section—that incremental testing is superior to nonincremental testing—two incremental strategies are explored: top-down and bottom-up testing. Before discussing them, however, several misconceptions should be clarified. First, the terms "top-down testing," "bottom-down development," and "top-down design" are often used as synonyms. Top-down testing and top-down development are synonyms (they represent a strategy of ordering the coding and testing of modules), but top-down design is something quite different and independent. A program that was designed in top-down fashioncan be incrementally tested in either a top-down or a bottom-up fashion.

Second, bottom-up testing (or bottom-up development) is often mistakenly equated with nonincremental testing. The reason is that bottom-up testing begins in a manner that is identical to a nonincremental test (i.e., when the bottom, or terminal, modules are tested), but as we saw in the previous section, bottom-up testing is an incremental strategy. Finally, since both strategies are incremental, the advantages of incremental testing are not repeated here; only the differences between top-down and bottom-up testing are discussed.

5.3.1. Top-down Testing

The top-down strategy starts with the top, or initial, module in the program. After this, there is no single right procedure for selecting the next module to be incrementally tested; the only rule is that to beeligible ...

Get The Art of Software Testing, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.