lejosunit.framework
Class TestResult

java.lang.Object
  extended bylejosunit.framework.TestResult

public class TestResult
extends java.lang.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.

lejosunit changes:

Author:
Jochen Hiller
See Also:
Test

Constructor Summary
TestResult()
          Default constructor.
 
Method Summary
 void addError(Test test, java.lang.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 endTest(Test test)
          Informs the listener that a test was completed.
 int errorCount()
          Gets the number of detected errors.
 java.lang.Object[] errors()
          Returns an Enumeration for the errors
 int failureCount()
          Gets the number of detected failures.
 java.lang.Object[] failures()
          Returns an Enumeration for the failures.
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.
 void setListener(TestListener aListener)
          Registers a TestListener.
 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
 

Constructor Detail

TestResult

public TestResult()
Default constructor.

Method Detail

addError

public void addError(Test test,
                     java.lang.Throwable t)
Adds an error to the list of errors. The passed in exception caused the error.

Parameters:
test - the test to add to error list
t - the throwable to add to error list

addFailure

public void addFailure(Test test,
                       AssertionFailedError t)
Adds a failure to the list of failures. The passed in exception caused the failure.

Parameters:
test - the test to add to failure list
t - the throwable to add to failure list

setListener

public void setListener(TestListener aListener)
Registers a TestListener.

Parameters:
aListener - the listerner to set for the test result

endTest

public void endTest(Test test)
Informs the listener that a test was completed.

Parameters:
test - the test which indicates the end

errors

public java.lang.Object[] errors()
Returns an Enumeration for the errors

Returns:
an array of TestFailure. Can be an empty array.

failures

public java.lang.Object[] failures()
Returns an Enumeration for the failures.

Returns:
an array of TestFailure. Can be an empty array.

run

protected void run(TestCase test)
Runs a TestCase.

Parameters:
test - the test case which will be running.

runCount

public int runCount()
Gets the number of run tests.

Returns:
the number of tests

runProtected

public void runProtected(Test test,
                         Protectable p)
Runs a TestCase.

Parameters:
test - the test which have to be running
p - the protectable to catch all exceptions

shouldStop

public boolean shouldStop()
Checks whether the test run should stop.

Returns:
true, if test runner should stop the test suite

startTest

public void startTest(Test test)
Informs the result that a test will be started.

Parameters:
test - the test which indicates start of an test case

stop

public void stop()
Marks that the test run should stop.


errorCount

public int errorCount()
Gets the number of detected errors.

Returns:
the number of errors counted

failureCount

public int failureCount()
Gets the number of detected failures.

Returns:
the number of failures counted

wasSuccessful

public boolean wasSuccessful()
Returns whether the entire test was successful or not.

Returns:
true, if everything was successful


Copyright (C) 2003 Jochen Hiller. All Rights Reserved.