18.3. πŸ‘©β€πŸ’» Choosing Good Unit TestsΒΆ

When we write unit tests, we should consider significantly different valid inputs to the function.

For example, the input to the square function could be either a positive or negative value. These two different kinds of inputs give us two equivalence classes of inputs. We then choose an input from each of these classes. It is important to have at least one test for each equivalence class of inputs.

Semantic errors are often caused by improperly handling the boundaries between equivalence classes. The boundary for this problem is zero. It is important to have a test at each boundary.

Extend the program …

Starting on line 9, write two unit tests (that should pass) so that all input equivalence classes and boundaries are covered.

Next Section - 18.4. πŸ‘©β€πŸ’» Program Development