j2meunit.textui
Class TestRunner

java.lang.Object
  |
  +--j2meunit.textui.TestRunner
All Implemented Interfaces:
TestListener

public class TestRunner
extends java.lang.Object
implements TestListener

A command line based tool to run tests.

 java test.textui.TestRunner TestCaseClass
 
TestRunner expects the name of a TestCase class as argument. If this class defines a static suite method it will be invoked and the returned test is run. Otherwise all the methods starting with "test" having no arguments are run.

When the wait command line argument is given TestRunner waits until the users types RETURN.

TestRunner prints a trace as the tests are executed followed by a summary at the end.


Field Summary
protected  java.io.PrintStream fWriter
           
 
Constructor Summary
TestRunner()
          Default constructor.
TestRunner(java.io.PrintStream writer)
          Constructor with a specific output stream.
 
Method Summary
 void addError(Test test, java.lang.Throwable t)
          DOCUMENT ME!
 void addFailure(Test test, AssertionFailedError e)
          DOCUMENT ME!
protected  TestResult createTestResult()
          Creates the TestResult to be used for the test run.
protected  void doRun(Test suite)
          DOCUMENT ME!
 void endTest(Test test)
          DOCUMENT ME!
 void endTestStep(Test test)
          TestListener.endTestStep()
static void main(java.lang.String[] args)
          main entry point.
 void print(TestResult result)
          Prints failures to the standard output
 void printErrors(TestResult result)
          Prints the errors to the standard output
 void printFailures(TestResult result)
          Prints failures to the standard output
 void printHeader(TestResult result)
          Prints the header of the report
protected  java.lang.String processArguments(java.lang.String[] args)
          Starts a test run.
static void run(Test suite)
          Runs a single test and collects its results.
protected  void start(java.lang.String[] args)
          Starts a test run.
 void startTest(Test test)
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fWriter

protected java.io.PrintStream fWriter
Constructor Detail

TestRunner

public TestRunner()
Default constructor.


TestRunner

public TestRunner(java.io.PrintStream writer)
Constructor with a specific output stream.

Parameters:
writer - The PrintStream to write the results to
Method Detail

addError

public void addError(Test test,
                     java.lang.Throwable t)
DOCUMENT ME!

Specified by:
addError in interface TestListener
Parameters:
test - DOCUMENT ME!
t - DOCUMENT ME!

addFailure

public void addFailure(Test test,
                       AssertionFailedError e)
DOCUMENT ME!

Specified by:
addFailure in interface TestListener
Parameters:
test - DOCUMENT ME!
e - DOCUMENT ME!

endTest

public void endTest(Test test)
DOCUMENT ME!

Specified by:
endTest in interface TestListener
Parameters:
test - DOCUMENT ME!

endTestStep

public void endTestStep(Test test)
TestListener.endTestStep()

Specified by:
endTestStep in interface TestListener
Parameters:
test - The test of which a step has finished

main

public static void main(java.lang.String[] args)
main entry point.

Parameters:
args - DOCUMENT ME!

print

public void print(TestResult result)
Prints failures to the standard output

Parameters:
result - DOCUMENT ME!

printErrors

public void printErrors(TestResult result)
Prints the errors to the standard output

Parameters:
result - DOCUMENT ME!

printFailures

public void printFailures(TestResult result)
Prints failures to the standard output

Parameters:
result - DOCUMENT ME!

printHeader

public void printHeader(TestResult result)
Prints the header of the report

Parameters:
result - DOCUMENT ME!

run

public static void run(Test suite)
Runs a single test and collects its results. This method can be used to start a test run from your program.
 public static void main (String[] args) {
     test.textui.TestRunner.run(suite());
 }
 

Parameters:
suite - DOCUMENT ME!

startTest

public void startTest(Test test)
DOCUMENT ME!

Specified by:
startTest in interface TestListener
Parameters:
test - DOCUMENT ME!

createTestResult

protected TestResult createTestResult()
Creates the TestResult to be used for the test run.

Returns:
DOCUMENT ME!

doRun

protected void doRun(Test suite)
DOCUMENT ME!

Parameters:
suite - DOCUMENT ME!

processArguments

protected java.lang.String processArguments(java.lang.String[] args)
Starts a test run. Analyzes the command line arguments and runs the given test suite.

Parameters:
args - DOCUMENT ME!
Returns:
DOCUMENT ME!

start

protected void start(java.lang.String[] args)
Starts a test run. Analyzes the command line arguments and runs the given test suite.

Parameters:
args - DOCUMENT ME!