The tester library includes a class tester.Main
that defines the start of the program, i.e. it defines the method
public static void main(String[] args)that runs the program.
This is the primary way for a novice user to run the tests. If the sample data and all test methods are defined in the class
named Examples the programmer just needs to declare that the program's
public static void main(String[] args) method can be found in the class
tester.Main.
In Eclipse this is done by defining a Run Configuration, in other IDEs one needs to set up the
project parameters in a similar way. Please, see the Select Reports
section for instructions relevant for the BlueJ users.
The main method in the class
tester.Main
starts the test run by looking for the class or classes that contain test methods.
The programmer can identify the classes that contain the test methods in several ways:
The simplest case is if all data and test cases are defined in the class named
Examples.
The tester finds all methods in that class with names that start with
test. Those methods are then run as the test methods.
Note that these methods must take a Tester
object as an argument; not doing so will cause the program to throw an error.
Note that the order in which the test methods are invoked is not specified.
The programmer may decide to name the class with a more relevant name, e.g.
ExamplesBooks and organize the code in the
package called books.
The main
method in the class tester.Main needs to receive the name
of this class as its argument. In this case it would be
"books.ExamplesBooks".
Consult your IDEs for instructions on
providing run-time arguments to the main method.
The programmer may define the tests in a class that implements the
"IExamples" interface. This alternative lets the programmer
determine exactly which test methods should be invoked for this test run.
See the Select Tests link for details.
The programmer may define the tests in a several classes and name the methods with
arbitrary names, providing the information about them through the use of Annotations.
See the Annotations link for details. If the programmer uses the relevant
Annotations in any classes involved in the test run, the test cases defined there will run
before the tests defined in the "Examples" class or in the
class whose name has been provided as the run-time argument to the
main method.