JavaLib
 
Tester
 
Setup
 
Main
Annotations
Select Tests
Select Reports
 
Sources
Downloads
 
TSRJ Home
TSRJ Local

Selecting the details reported by the tester

The Tester's run, runReport, runReports, and runFullReport methods


The programmer can evaluate tests defined in any class by providing an instance of that class to one of the four variants of static run methods defined in the Tester class.

Typically, these methods should be invoked in the public static void main(String[] args) method of one of the classes in the project, following the typical standard Java practice. These methods eliminate the need set up special run configurations. This is especially valuable to those using the BlueJ IDE that requires the main method to be defined in one of the project's classes.

The programmer still defines a class that contains all test methods and passes to the run method an instance of this class. The last variant allows the programmer to define tests in several distinct classes and pass the instances of all of them to the run method for evaluation. The rules for the test definition and reporting of the results are the same regardless of how the test evaluation and reporting is invoked.

  • Run is the default variant. By calling the static void Tester.run(Object obj) method, where obj is an instance of the class you wish to use as your examples class, all test methods contained within that class will be performed on the obj instance of that class. The report will show all the results of all failed tests.

  • Run Full Report describes a comprehensive variant. This refers to the static void Tester.runFullReport(Object obj) method. It serves the same purpose as the previous variant. However, here the tester prints the values of all fields in the given example class as well as the results of all tests, successful and failed.

  • Run Report describes an optional variant. This style refers to the static void Tester.runReport(Object obj, boolean full, boolean printall) method. This give you the control over the nature of the report the tester produces. If boolean full is true, you will see the printout of both the successful and the failed tests, otherwise only the failed test results are shown. If boolean printall is true, you will receive a text representation of the obj (it will print the values of all of obj's fields).

  • Run Reports describes another optional variant. This style refers to the static void Tester.runReport(boolean full, boolean printall, Object... objs) This works the same way as runReport but it allows you to run tests on an arbitrary number of instances of classes containing test methods.


If you desire to have more localized, direct control over your testing, these are the methods for you. They are hooks into the same code in the Tester class that the Main class eventually calls. The main differences are that these methods give you control over what kind of reporting you receive. Additionally, because these methods are called in your main function, it lends your testing toward a natural kind of organization.

You may need to use one of these functions depending on your IDE. If you or your IDE does not have the capacity to point your compiler to the Main class's main method, this might be your only solution. BlueJ is an instance of one such IDE that requires the use of one of these functions.



last updated on Fri Apr 1 14:26:43 EDT 2011generated with DrRacket