public class

TestResult

extends Object
java.lang.Object
   ↳ junit.framework.TestResult

Class Overview

A TestResult collects the results of executing a test case. It is an instance of the Collecting Parameter pattern. The test framework distinguishes between failures and errors. A failure is anticipated and checked for with assertions. Errors are unanticipated problems like an ArrayIndexOutOfBoundsException.

See Also

Summary

Fields
protected Vector fErrors
protected Vector fFailures
protected Vector fListeners
protected int fRunTests
Public Constructors
TestResult()
Public Methods
synchronized void addError(Test test, Throwable t)
Adds an error to the list of errors.
synchronized void addFailure(Test test, AssertionFailedError t)
Adds a failure to the list of failures.
synchronized void addListener(TestListener listener)
Registers a TestListener
void endTest(Test test)
Informs the result that a test was completed.
synchronized int errorCount()
Gets the number of detected errors.
synchronized Enumeration errors()
Returns an Enumeration for the errors
synchronized int failureCount()
Gets the number of detected failures.
synchronized Enumeration failures()
Returns an Enumeration for the failures
synchronized void removeListener(TestListener listener)
Unregisters a TestListener
synchronized int runCount()
Gets the number of run tests.
void runProtected(Test test, Protectable p)
Runs a TestCase.
synchronized boolean shouldStop()
Checks whether the test run should stop
void startTest(Test test)
Informs the result that a test will be started.
synchronized void stop()
Marks that the test run should stop.
synchronized boolean wasSuccessful()
Returns whether the entire test was successful or not.
Protected Methods
void run(TestCase test)
Runs a TestCase.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected Vector fErrors

Since: API Level 1

protected Vector fFailures

Since: API Level 1

protected Vector fListeners

Since: API Level 1

protected int fRunTests

Since: API Level 1

Public Constructors

public TestResult ()

Since: API Level 1

Public Methods

public synchronized void addError (Test test, Throwable t)

Since: API Level 1

Adds an error to the list of errors. The passed in exception caused the error.

public synchronized void addFailure (Test test, AssertionFailedError t)

Since: API Level 1

Adds a failure to the list of failures. The passed in exception caused the failure.

public synchronized void addListener (TestListener listener)

Since: API Level 1

Registers a TestListener

public void endTest (Test test)

Since: API Level 1

Informs the result that a test was completed.

public synchronized int errorCount ()

Since: API Level 1

Gets the number of detected errors.

public synchronized Enumeration errors ()

Since: API Level 1

Returns an Enumeration for the errors

public synchronized int failureCount ()

Since: API Level 1

Gets the number of detected failures.

public synchronized Enumeration failures ()

Since: API Level 1

Returns an Enumeration for the failures

public synchronized void removeListener (TestListener listener)

Since: API Level 1

Unregisters a TestListener

public synchronized int runCount ()

Since: API Level 1

Gets the number of run tests.

public void runProtected (Test test, Protectable p)

Since: API Level 1

Runs a TestCase.

public synchronized boolean shouldStop ()

Since: API Level 1

Checks whether the test run should stop

public void startTest (Test test)

Since: API Level 1

Informs the result that a test will be started.

public synchronized void stop ()

Since: API Level 1

Marks that the test run should stop.

public synchronized boolean wasSuccessful ()

Since: API Level 1

Returns whether the entire test was successful or not.

Protected Methods

protected void run (TestCase test)

Since: API Level 1

Runs a TestCase.