Most visited

Recently visited

Added in API level 1

TestResult

public class TestResult
extends Object

java.lang.Object
   ↳ junit.framework.TestResult


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<TestFailure> fErrors

protected Vector<TestFailure> fFailures

protected Vector<TestListener> fListeners

protected int fRunTests

Public constructors

TestResult()

Public methods

void addError(Test test, Throwable t)

Adds an error to the list of errors.

void addFailure(Test test, AssertionFailedError t)

Adds a failure to the list of failures.

void addListener(TestListener listener)

Registers a TestListener

void endTest(Test test)

Informs the result that a test was completed.

int errorCount()

Gets the number of detected errors.

Enumeration<TestFailure> errors()

Returns an Enumeration for the errors

int failureCount()

Gets the number of detected failures.

Enumeration<TestFailure> failures()

Returns an Enumeration for the failures

void removeListener(TestListener listener)

Unregisters a TestListener

int runCount()

Gets the number of run tests.

void runProtected(Test test, Protectable p)

Runs a TestCase.

boolean shouldStop()

Checks whether the test run should stop

void startTest(Test test)

Informs the result that a test will be started.

void stop()

Marks that the test run should stop.

boolean wasSuccessful()

Returns whether the entire test was successful or not.

Protected methods

void run(TestCase test)

Runs a TestCase.

Inherited methods

From class java.lang.Object

Fields

fErrors

Added in API level 1
Vector<TestFailure> fErrors

fFailures

Added in API level 1
Vector<TestFailure> fFailures

fListeners

Added in API level 1
Vector<TestListener> fListeners

fRunTests

Added in API level 1
int fRunTests

Public constructors

TestResult

Added in API level 1
TestResult ()

Public methods

addError

Added in API level 1
void addError (Test test, 
                Throwable t)

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

Parameters
test Test
t Throwable

addFailure

Added in API level 1
void addFailure (Test test, 
                AssertionFailedError t)

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

Parameters
test Test
t AssertionFailedError

addListener

Added in API level 1
void addListener (TestListener listener)

Registers a TestListener

Parameters
listener TestListener

endTest

Added in API level 1
void endTest (Test test)

Informs the result that a test was completed.

Parameters
test Test

errorCount

Added in API level 1
int errorCount ()

Gets the number of detected errors.

Returns
int

errors

Added in API level 1
Enumeration<TestFailure> errors ()

Returns an Enumeration for the errors

Returns
Enumeration<TestFailure>

failureCount

Added in API level 1
int failureCount ()

Gets the number of detected failures.

Returns
int

failures

Added in API level 1
Enumeration<TestFailure> failures ()

Returns an Enumeration for the failures

Returns
Enumeration<TestFailure>

removeListener

Added in API level 1
void removeListener (TestListener listener)

Unregisters a TestListener

Parameters
listener TestListener

runCount

Added in API level 1
int runCount ()

Gets the number of run tests.

Returns
int

runProtected

Added in API level 1
void runProtected (Test test, 
                Protectable p)

Runs a TestCase.

Parameters
test Test
p Protectable

shouldStop

Added in API level 1
boolean shouldStop ()

Checks whether the test run should stop

Returns
boolean

startTest

Added in API level 1
void startTest (Test test)

Informs the result that a test will be started.

Parameters
test Test

stop

Added in API level 1
void stop ()

Marks that the test run should stop.

wasSuccessful

Added in API level 1
boolean wasSuccessful ()

Returns whether the entire test was successful or not.

Returns
boolean

Protected methods

run

Added in API level 1
void run (TestCase test)

Runs a TestCase.

Parameters
test TestCase

Hooray!