public class

TestRunner

extends BaseTestRunner
java.lang.Object
   ↳ junit.runner.BaseTestRunner
     ↳ junit.textui.TestRunner

Class Overview

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.

Summary

Constants
int EXCEPTION_EXIT
int FAILURE_EXIT
int SUCCESS_EXIT
[Expand]
Inherited Constants
From class junit.runner.BaseTestRunner
Public Constructors
TestRunner()
Constructs a TestRunner.
TestRunner(PrintStream writer)
Constructs a TestRunner using the given stream for all the output
TestRunner(ResultPrinter printer)
Constructs a TestRunner using the given ResultPrinter all the output
Public Methods
TestResult doRun(Test test)
TestResult doRun(Test suite, boolean wait)
static void main(String[] args)
static void run(Class<? extends TestCase> testClass)
Runs a suite extracted from a TestCase subclass.
static TestResult run(Test test)
Runs a single test and collects its results.
static void runAndWait(Test suite)
Runs a single test and waits until the user types RETURN.
void setPrinter(ResultPrinter printer)
TestResult start(String[] args)
Starts a test run.
void testEnded(String testName)
void testFailed(int status, Test test, Throwable t)
void testStarted(String testName)
Protected Methods
TestResult createTestResult()
Creates the TestResult to be used for the test run.
void pause(boolean wait)
void runFailed(String message)
Override to define how to handle a failed loading of a test suite.
TestResult runSingleMethod(String testCase, String method, boolean wait)
[Expand]
Inherited Methods
From class junit.runner.BaseTestRunner
From class java.lang.Object
From interface junit.framework.TestListener

Constants

public static final int EXCEPTION_EXIT

Constant Value: 2 (0x00000002)

public static final int FAILURE_EXIT

Constant Value: 1 (0x00000001)

public static final int SUCCESS_EXIT

Constant Value: 0 (0x00000000)

Public Constructors

public TestRunner ()

Constructs a TestRunner.

public TestRunner (PrintStream writer)

Constructs a TestRunner using the given stream for all the output

public TestRunner (ResultPrinter printer)

Constructs a TestRunner using the given ResultPrinter all the output

Public Methods

public TestResult doRun (Test test)

public TestResult doRun (Test suite, boolean wait)

public static void main (String[] args)

public static void run (Class<? extends TestCase> testClass)

Runs a suite extracted from a TestCase subclass.

public static TestResult run (Test test)

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());
 }
 

public static void runAndWait (Test suite)

Runs a single test and waits until the user types RETURN.

public void setPrinter (ResultPrinter printer)

public TestResult start (String[] args)

Starts a test run. Analyzes the command line arguments and runs the given test suite.

Throws
Exception

public void testEnded (String testName)

public void testFailed (int status, Test test, Throwable t)

public void testStarted (String testName)

Protected Methods

protected TestResult createTestResult ()

Creates the TestResult to be used for the test run.

protected void pause (boolean wait)

protected void runFailed (String message)

Override to define how to handle a failed loading of a test suite.

protected TestResult runSingleMethod (String testCase, String method, boolean wait)

Throws
Exception