ABSTRACT

The main question for class testing is whether a class or a method is a unit. Most of the o-o literature leans toward the class-as-unit side, but this definition has problems. In traditional software (where it is also hard to find a definition of a unit), the common guidelines are that a unit is:

The smallest chunk that can be compiled by itself A single procedure/function (stand-alone) Something so small it would be developed by one person

These guidelines also make sense for o-o software, but they do not resolve whether classes or methods should be considered as units. A method implements a single function, and it would not be assigned to more than one person, so methods might legitimately be considered units. The smallest compilation requirement is problematic. Technically, we could compile a single-method class by ignoring the other methods in the class (probably by commenting them out), but this creates an organizational mess. We will present both views of o-o unit testing; you can let particular circumstances decide which is more appropriate.