TestResult (see Figure B-9) is a class used to collect unit test results. The information collected includes a count of tests run and any failures or errors produced. Failures and errors are represented as instances of TestFailure . A TestResult runs a Test by calling its runBare( ) method.
A set of unit tests is run by creating an empty TestResult and calling run(TestResult) on each Test , passing the TestResult as a collecting parameter. At the end, the set of results is retrieved from the TestResult and reported .
A TestResult also is created when the method Test.run( ) is used to execute a Test .
public class TestResult extends Object
A constructor creating an empty TestResult .
Adds an error to the results.
Adds a failure to the results.
Registers a TestListener to receive events from this TestResult .
Informs the listeners that Test completed.
Gets the number of errors in the results.
Gets an Enumeration of the errors.
Gets the number of failures in the results.
Gets an Enumeration of the failures.
Unregisters a TestListener .
Gets the number of tests run.
Runs a Protectable and associates any failures or errors with Test . The Protectable is assumed to run the Test 's test method.
Returns the stop flag.
Informs listeners that Test is starting. Also increments fRunTests by the amount returned by Test.countTestCases( ) .
Sets the stop flag.
Returns TRUE if there are no failures or errors in the results.
A method to run a TestCase .
A method to return a copy of the listeners.
A collection of TestFailures representing errors.
A collection of TestFailures representing failures.
A list of TestListeners for this TestResult .
A counter to record the number of tests run.
A stop flag indicating that tests should stop running.