Chapter 2. Basics of Unit Testing
In this chapter, we will write and test a simple class. This will demonstrate how the "test first" approach introduced in Chapter 1 can be applied in practice. We'll also look at the use of "Design by Contract", and the form that unit tests take.
A Simple Example
Suppose we are implementing a collection class Relation
representing a mathematical relation. A Relation
of size N simply consists of a set of pairs of objects (ai, bi), where i = 1, 2,…, N. The set of objects {ai} is called the domain, and the set of objects {bi} is called the range.

A relation between the letters {A, B, C} and the numbers {1, 2, 3, 4} is ...
Get Swing Extreme Testing now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.