org.jlf.util
Class JUnitTestRunner

java.lang.Object
  |
  +--junit.runner.BaseTestRunner
        |
        +--org.jlf.util.JUnitTestRunner
All Implemented Interfaces:
junit.framework.TestListener

public class JUnitTestRunner
extends junit.runner.BaseTestRunner

This class is an enhanced version of the JUnit junit.textui.TestRunner class to be run inside a servlet/JSP with an output writer. Here is the remainder of the class definition from JUnit: A command line based tool to run tests.

 java junit.textui.TestRunner [-wait] 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
 
Fields inherited from class junit.runner.BaseTestRunner
SUITE_METHODNAME
 
Constructor Summary
JUnitTestRunner()
          Constructs a TestRunner.
JUnitTestRunner(java.io.PrintWriter writer)
          Constructs a TestRunner using the print stream for all the output
 
Method Summary
 void addError(junit.framework.Test test, java.lang.Throwable t)
           
 void addFailure(junit.framework.Test test, junit.framework.AssertionFailedError t)
           
protected  junit.framework.TestResult createTestResult()
          Creates the TestResult to be used for the test run.
 junit.framework.TestResult doRun(junit.framework.Test suite, boolean wait)
           
 void endTest(junit.framework.Test test)
           
 junit.runner.TestSuiteLoader getLoader()
          Always use the StandardTestSuiteLoader.
static void main(java.lang.String[] args)
           
protected  void pause(boolean wait)
           
 void print(junit.framework.TestResult result)
          Prints failures to the standard output
 void printErrors(junit.framework.TestResult result)
          Prints the errors to the standard output
 void printFailures(junit.framework.TestResult result)
          Prints failures to the standard output
 void printHeader(junit.framework.TestResult result)
          Prints the header of the report
static void run(java.lang.Class testClass)
          Runs a suite extracted from a TestCase subclass.
static void run(junit.framework.Test suite)
          Runs a single test and collects its results.
static void runAndWait(junit.framework.Test suite)
          Runs a single test and waits until the user types RETURN.
protected  void runFailed(java.lang.String message)
           
 junit.framework.TestResult start(java.lang.String[] args)
          Starts a test run.
 void startTest(junit.framework.Test test)
           
protected  java.io.PrintWriter writer()
           
 
Methods inherited from class junit.runner.BaseTestRunner
clearStatus, elapsedTimeAsString, extractClassName, filterStack, getFilteredTrace, getPreference, getPreference, getTest, inVAJava, loadSuiteClass, processArguments, setLoading, truncate, useReloadingTestSuiteLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JUnitTestRunner

public JUnitTestRunner()
Constructs a TestRunner.


JUnitTestRunner

public JUnitTestRunner(java.io.PrintWriter writer)
Constructs a TestRunner using the print stream for all the output

Method Detail

getLoader

public junit.runner.TestSuiteLoader getLoader()
Always use the StandardTestSuiteLoader. Overridden from BaseTestRunner.

Overrides:
getLoader in class junit.runner.BaseTestRunner

addError

public void addError(junit.framework.Test test,
                     java.lang.Throwable t)
Specified by:
addError in interface junit.framework.TestListener
Specified by:
addError in class junit.runner.BaseTestRunner

addFailure

public void addFailure(junit.framework.Test test,
                       junit.framework.AssertionFailedError t)
Specified by:
addFailure in interface junit.framework.TestListener
Specified by:
addFailure in class junit.runner.BaseTestRunner

createTestResult

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


doRun

public junit.framework.TestResult doRun(junit.framework.Test suite,
                                        boolean wait)

pause

protected void pause(boolean wait)

startTest

public void startTest(junit.framework.Test test)
Specified by:
startTest in interface junit.framework.TestListener
Specified by:
startTest in class junit.runner.BaseTestRunner

endTest

public void endTest(junit.framework.Test test)
Specified by:
endTest in interface junit.framework.TestListener
Specified by:
endTest in class junit.runner.BaseTestRunner

main

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

print

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


printErrors

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


printFailures

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


printHeader

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


run

public static void run(java.lang.Class testClass)
Runs a suite extracted from a TestCase subclass.


run

public static void run(junit.framework.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());
 }
 


runAndWait

public static void runAndWait(junit.framework.Test suite)
Runs a single test and waits until the user types RETURN.


start

public junit.framework.TestResult start(java.lang.String[] args)
                                 throws java.lang.Exception
Starts a test run. Analyzes the command line arguments and runs the given test suite.

java.lang.Exception

runFailed

protected void runFailed(java.lang.String message)
Specified by:
runFailed in class junit.runner.BaseTestRunner

writer

protected java.io.PrintWriter writer()