public class TestResult
extends java.lang.Object
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
.Test
Modifier and Type | Field and Description |
---|---|
protected java.util.List<TestFailure> |
fErrors |
protected java.util.List<TestFailure> |
fFailures |
protected java.util.List<TestListener> |
fListeners |
protected int |
fRunTests |
private boolean |
fStop |
Constructor and Description |
---|
TestResult() |
Modifier and Type | Method and Description |
---|---|
void |
addError(Test test,
java.lang.Throwable e)
Adds an error to the list of errors.
|
void |
addFailure(Test test,
AssertionFailedError e)
Adds a failure to the list of failures.
|
void |
addListener(TestListener listener)
Registers a TestListener.
|
private java.util.List<TestListener> |
cloneListeners()
Returns a copy of the listeners.
|
void |
endTest(Test test)
Informs the result that a test was completed.
|
int |
errorCount()
Gets the number of detected errors.
|
java.util.Enumeration<TestFailure> |
errors()
Returns an Enumeration for the errors.
|
int |
failureCount()
Gets the number of detected failures.
|
java.util.Enumeration<TestFailure> |
failures()
Returns an Enumeration for the failures.
|
void |
removeListener(TestListener listener)
Unregisters a TestListener.
|
protected void |
run(TestCase test)
Runs a TestCase.
|
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 java.util.List<TestFailure> fFailures
protected java.util.List<TestFailure> fErrors
protected java.util.List<TestListener> fListeners
protected int fRunTests
private boolean fStop
public void addError(Test test, java.lang.Throwable e)
public void addFailure(Test test, AssertionFailedError e)
public void addListener(TestListener listener)
public void removeListener(TestListener listener)
private java.util.List<TestListener> cloneListeners()
public void endTest(Test test)
public int errorCount()
public java.util.Enumeration<TestFailure> errors()
public int failureCount()
public java.util.Enumeration<TestFailure> failures()
protected void run(TestCase test)
public int runCount()
public void runProtected(Test test, Protectable p)
public boolean shouldStop()
public void startTest(Test test)
public void stop()
public boolean wasSuccessful()