BaseTestRunner

public abstract class BaseTestRunner
extends Object implements TestListener

java.lang.Object
   ↳ junit.runner.BaseTestRunner


Base class for all test runners. This class was born live on stage in Sardinia during XP2000.

Summary

Constants

String SUITE_METHODNAME

Public constructors

BaseTestRunner()

Public methods

void addError(Test test, Throwable t)

An error occurred.

void addFailure(Test test, AssertionFailedError t)

A failure occurred.

String elapsedTimeAsString(long runTime)

Returns the formatted string of the elapsed time.

void endTest(Test test)

A test ended.

String extractClassName(String className)

Extract the class name from a String in VA/Java style

static String getFilteredTrace(String stack)

Filters stack frames from internal JUnit classes

static String getFilteredTrace(Throwable t)

Returns a filtered stack trace

TestSuiteLoader getLoader()

This method was deprecated in API level 16. not present in JUnit4.10

static int getPreference(String key, int dflt)
static String getPreference(String key)
Test getTest(String suiteClassName)

Returns the Test corresponding to the given suite.

static boolean inVAJava()

This method was deprecated in API level 16. not present in JUnit4.10

static void savePreferences()
void setLoading(boolean enable)

Sets the loading behaviour of the test runner

void setPreference(String key, String value)
void startTest(Test test)

A test started.

abstract void testEnded(String testName)
abstract void testFailed(int status, Test test, Throwable t)
abstract void testStarted(String testName)
static String truncate(String s)

Truncates a String to the maximum length.

Protected methods

void clearStatus()

Clears the status message.

static Properties getPreferences()
Class<?> loadSuiteClass(String suiteClassName)

Returns the loaded Class for a suite name.

String processArguments(String[] args)

Processes the command line arguments and returns the name of the suite class to run or null

abstract void runFailed(String message)

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

static void setPreferences(Properties preferences)
static boolean showStackRaw()
boolean useReloadingTestSuiteLoader()

Inherited methods

Constants

SUITE_METHODNAME

Added in API level 1
public static final String SUITE_METHODNAME

Constant Value: "suite"

Public constructors

BaseTestRunner

public BaseTestRunner ()

Public methods

addError

Added in API level 1
public void addError (Test test, 
                Throwable t)

An error occurred.

Parameters
test Test

t Throwable

addFailure

Added in API level 1
public void addFailure (Test test, 
                AssertionFailedError t)

A failure occurred.

Parameters
test Test

t AssertionFailedError

elapsedTimeAsString

Added in API level 1
public String elapsedTimeAsString (long runTime)

Returns the formatted string of the elapsed time.

Parameters
runTime long

Returns
String

endTest

Added in API level 1
public void endTest (Test test)

A test ended.

Parameters
test Test

extractClassName

Added in API level 1
public String extractClassName (String className)

Extract the class name from a String in VA/Java style

Parameters
className String

Returns
String

getFilteredTrace

Added in API level 1
public static String getFilteredTrace (String stack)

Filters stack frames from internal JUnit classes

Parameters
stack String

Returns
String

getFilteredTrace

Added in API level 1
public static String getFilteredTrace (Throwable t)

Returns a filtered stack trace

Parameters
t Throwable

Returns
String

getLoader

Added in API level 1
Deprecated in API level 16
public TestSuiteLoader getLoader ()

This method was deprecated in API level 16.
not present in JUnit4.10

Returns the loader to be used.

Returns
TestSuiteLoader

getPreference

Added in API level 1
public static int getPreference (String key, 
                int dflt)

Parameters
key String

dflt int

Returns
int

getPreference

Added in API level 1
public static String getPreference (String key)

Parameters
key String

Returns
String

getTest

Added in API level 1
public Test getTest (String suiteClassName)

Returns the Test corresponding to the given suite. This is a template method, subclasses override runFailed(), clearStatus().

Parameters
suiteClassName String

Returns
Test

inVAJava

Added in API level 1
Deprecated in API level 16
public static boolean inVAJava ()

This method was deprecated in API level 16.
not present in JUnit4.10

Returns
boolean

savePreferences

Added in API level 1
public static void savePreferences ()

Throws
IOException

setLoading

Added in API level 1
public void setLoading (boolean enable)

Sets the loading behaviour of the test runner

Parameters
enable boolean

setPreference

Added in API level 1
public void setPreference (String key, 
                String value)

Parameters
key String

value String

startTest

Added in API level 1
public void startTest (Test test)

A test started.

Parameters
test Test

testEnded

Added in API level 1
public abstract void testEnded (String testName)

Parameters
testName String

testFailed

Added in API level 1
public abstract void testFailed (int status, 
                Test test, 
                Throwable t)

Parameters
status int

test Test

t Throwable

testStarted

Added in API level 1
public abstract void testStarted (String testName)

Parameters
testName String

truncate

Added in API level 1
public static String truncate (String s)

Truncates a String to the maximum length.

Parameters
s String

Returns
String

Protected methods

clearStatus

Added in API level 1
protected void clearStatus ()

Clears the status message.

getPreferences

Added in API level 1
protected static Properties getPreferences ()

Returns
Properties

loadSuiteClass

Added in API level 1
protected Class<?> loadSuiteClass (String suiteClassName)

Returns the loaded Class for a suite name.

Parameters
suiteClassName String

Returns
Class<?>

Throws
ClassNotFoundException

processArguments

Added in API level 1
protected String processArguments (String[] args)

Processes the command line arguments and returns the name of the suite class to run or null

Parameters
args String

Returns
String

runFailed

Added in API level 1
protected abstract void runFailed (String message)

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

Parameters
message String

setPreferences

Added in API level 1
protected static void setPreferences (Properties preferences)

Parameters
preferences Properties

showStackRaw

Added in API level 1
protected static boolean showStackRaw ()

Returns
boolean

useReloadingTestSuiteLoader

Added in API level 1
protected boolean useReloadingTestSuiteLoader ()

Returns
boolean