Package junit.framework
Class TestResult
- java.lang.Object
-
- junit.framework.TestResult
-
public class TestResult extends java.lang.ObjectATestResultcollects 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 anArrayIndexOutOfBoundsException.- See Also:
Test
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<TestFailure>fErrorsprotected java.util.List<TestFailure>fFailuresprotected java.util.List<TestListener>fListenersprotected intfRunTestsprivate booleanfStop
-
Constructor Summary
Constructors Constructor Description TestResult()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddError(Test test, java.lang.Throwable e)Adds an error to the list of errors.voidaddFailure(Test test, AssertionFailedError e)Adds a failure to the list of failures.voidaddListener(TestListener listener)Registers a TestListener.private java.util.List<TestListener>cloneListeners()Returns a copy of the listeners.voidendTest(Test test)Informs the result that a test was completed.interrorCount()Gets the number of detected errors.java.util.Enumeration<TestFailure>errors()Returns an Enumeration for the errors.intfailureCount()Gets the number of detected failures.java.util.Enumeration<TestFailure>failures()Returns an Enumeration for the failures.voidremoveListener(TestListener listener)Unregisters a TestListener.protected voidrun(TestCase test)Runs a TestCase.intrunCount()Gets the number of run tests.voidrunProtected(Test test, Protectable p)Runs a TestCase.booleanshouldStop()Checks whether the test run should stop.voidstartTest(Test test)Informs the result that a test will be started.voidstop()Marks that the test run should stop.booleanwasSuccessful()Returns whether the entire test was successful or not.
-
-
-
Field Detail
-
fFailures
protected java.util.List<TestFailure> fFailures
-
fErrors
protected java.util.List<TestFailure> fErrors
-
fListeners
protected java.util.List<TestListener> fListeners
-
fRunTests
protected int fRunTests
-
fStop
private boolean fStop
-
-
Method Detail
-
addError
public void addError(Test test, java.lang.Throwable e)
Adds an error to the list of errors. The passed in exception caused the error.
-
addFailure
public void addFailure(Test test, AssertionFailedError e)
Adds a failure to the list of failures. The passed in exception caused the failure.
-
addListener
public void addListener(TestListener listener)
Registers a TestListener.
-
removeListener
public void removeListener(TestListener listener)
Unregisters a TestListener.
-
cloneListeners
private java.util.List<TestListener> cloneListeners()
Returns a copy of the listeners.
-
endTest
public void endTest(Test test)
Informs the result that a test was completed.
-
errorCount
public int errorCount()
Gets the number of detected errors.
-
errors
public java.util.Enumeration<TestFailure> errors()
Returns an Enumeration for the errors.
-
failureCount
public int failureCount()
Gets the number of detected failures.
-
failures
public java.util.Enumeration<TestFailure> failures()
Returns an Enumeration for the failures.
-
run
protected void run(TestCase test)
Runs a TestCase.
-
runCount
public int runCount()
Gets the number of run tests.
-
runProtected
public void runProtected(Test test, Protectable p)
Runs a TestCase.
-
shouldStop
public boolean shouldStop()
Checks whether the test run should stop.
-
startTest
public void startTest(Test test)
Informs the result that a test will be started.
-
stop
public void stop()
Marks that the test run should stop.
-
wasSuccessful
public boolean wasSuccessful()
Returns whether the entire test was successful or not.
-
-