Package junit.framework
Class TestResult
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<TestFailure> protected List<TestFailure> protected List<TestListener> protected intprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds 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 List<TestListener> Returns a copy of the listeners.voidInforms the result that a test was completed.intGets the number of detected errors.errors()Returns an Enumeration for the errors.intGets the number of detected failures.failures()Returns an Enumeration for the failures.voidremoveListener(TestListener listener) Unregisters a TestListener.protected voidRuns a TestCase.intrunCount()Gets the number of run tests.voidrunProtected(Test test, Protectable p) Runs a TestCase.booleanChecks whether the test run should stop.voidInforms the result that a test will be started.voidstop()Marks that the test run should stop.booleanReturns whether the entire test was successful or not.
-
Field Details
-
fFailures
-
fErrors
-
fListeners
-
fRunTests
protected int fRunTests -
fStop
private boolean fStop
-
-
Constructor Details
-
TestResult
public TestResult()
-
-
Method Details
-
addError
Adds an error to the list of errors. The passed in exception caused the error. -
addFailure
Adds a failure to the list of failures. The passed in exception caused the failure. -
addListener
Registers a TestListener. -
removeListener
Unregisters a TestListener. -
cloneListeners
Returns a copy of the listeners. -
endTest
Informs the result that a test was completed. -
errorCount
public int errorCount()Gets the number of detected errors. -
errors
Returns an Enumeration for the errors. -
failureCount
public int failureCount()Gets the number of detected failures. -
failures
Returns an Enumeration for the failures. -
run
Runs a TestCase. -
runCount
public int runCount()Gets the number of run tests. -
runProtected
Runs a TestCase. -
shouldStop
public boolean shouldStop()Checks whether the test run should stop. -
startTest
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.
-