-
Book Overview & Buying
-
Table Of Contents
Hands-On Software Engineering with Python - Second Edition
By :
Unit testing is the foundation of a disciplined testing process for code. The intent behind a unit test suite is to test individual code components within a codebase, at some acceptable level of isolation from other components in the codebase, in order to verify that each of those components behaves in a predictable fashion. Note that nowhere in that definition did the terms bug or defect (or any other synonym for them) appear. The distinction between unpredictable behavior and undesirable behavior (a bug or defect) is subtle, but noteworthy. Odds are good that unpredictable behavior will also be undesirable behavior, but the two are not always the same: it’s possible, however unlikely, that unpredictable behavior will not be unwanted.
The idea of testing for predictable behavior also includes the potential for code to raise errors under certain circumstances. For example, if a chunk of code is written so that it with some variant of the supported...