This page describes how to run tests defined in one or more example classes.
The tester provides several ways in which the user can invoke the evaluation of all test cases
defined in a given class.
Where you place your tests and how much control you have over the testing process is entirely dependent
on which style you choose. The only hook the tester needs is for any
class that defines test methods to also define the default constructor
(it can be private.)
The simplest way to define and evaluate all tests is to place all test methods (with the needed data definitions)
into the Examples class and make sure the name of every test
method starts with test. The links on the left describe the alternative ways for defining tests,
evaluating them, and reporting the results.
Main describes the basic variant that relies on the tester's
Main class to find your
Examples class and run your tests for you.
This also describes how to specify a different name for the class that defines the test methods.
Annotations shows how the programmer can define the test cases in several classes
and give the test methods arbitrary names by using simple Java Annotations.
Select Tests shows how the programmer can decide which tests should be performed
by implementing the IExamples interface. The tester runs only the tests
that are invoked within a void tests(Tester t) method,
allowing the programmer to comment out unneeded tests easily.
Note: Make sure you understand how this technique interacts with the others, so
that you do not accidentally omit test cases or run the tests twice.
Select Reports shows how the programmer can decide what results should the
tester display. The user may want to see a display of all data, all tests, only the failed tests,
or the failed tests and warnings.
To customize the reports the relevant Tester methods
must be called in the public static void main(String[] args)
method of a class in your project.
These methods eliminate the need set up special run configurations, since you will create and run your
own main method.
This is especially valuable to those utilizing the BlueJ IDE (such users need these methods).