## junit.framework
Class TestResult

    java.lang.Object
      junit.framework.TestResult

    public class TestResult

extends Object

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:
  `Test`

Field Summary
`protected List<TestFailure>` `fErrors`
`protected List<TestFailure>` `fFailures`
`protected List<TestListener>` `fListeners`
`protected int` `fRunTests`

Constructor Summary
`TestResult()`

Method Summary
`void` `addError(Test test, 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.
`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.
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### fFailures

    protected List<TestFailure> fFailures

### fErrors

    protected List<TestFailure> fErrors

### fListeners

    protected List<TestListener> fListeners

### fRunTests

    protected int fRunTests

Constructor Detail

### TestResult

    public TestResult()

Method Detail

### addError

    public void addError(Test test,
                         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.

### 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 Enumeration<TestFailure> errors()

  Returns an Enumeration for the errors.

### failureCount

    public int failureCount()

  Gets the number of detected failures.

### failures

    public 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.

Copyright © 2002–2020 JUnit. All rights reserved.