Java Reference
In-Depth Information
To test a class, use an environment for interactive testing, or write a tester class to
execute test instructions.
1. Construct one or more objects of the class that is being tested.
2. Invoke one or more methods.
3. Print out one or more results.
4. Print the expected results.
Figure 6
The Return Value of the
getBalance
Method in BlueJ
102
103
The
MoveTester
class in
Section 2.8
is a good example of a tester class. That class
runs methods of the
Rectangle
classȌa class in the Java library.