Package junit.runner
Class BaseTestRunner
- java.lang.Object
-
- junit.runner.BaseTestRunner
-
- All Implemented Interfaces:
TestListener
- Direct Known Subclasses:
TestRunner
public abstract class BaseTestRunner extends java.lang.Object implements TestListener
Base class for all test runners. This class was born live on stage in Sardinia during XP2000.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
SUITE_METHODNAME
-
Constructor Summary
Constructors Constructor Description BaseTestRunner()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addError(Test test, java.lang.Throwable e)
An error occurred.void
addFailure(Test test, AssertionFailedError e)
A failure occurred.protected void
clearStatus()
Clears the status message.java.lang.String
elapsedTimeAsString(long runTime)
Returns the formatted string of the elapsed time.void
endTest(Test test)
A test ended.java.lang.String
extractClassName(java.lang.String className)
Extract the class name from a String in VA/Java stylestatic java.lang.String
getFilteredTrace(java.lang.String stack)
Filters stack frames from internal JUnit classesstatic java.lang.String
getFilteredTrace(java.lang.Throwable e)
Returns a filtered stack tracestatic java.lang.String
getPreference(java.lang.String key)
static int
getPreference(java.lang.String key, int dflt)
protected static java.util.Properties
getPreferences()
Test
getTest(java.lang.String suiteClassName)
Returns the Test corresponding to the given suite.protected java.lang.Class<?>
loadSuiteClass(java.lang.String suiteClassName)
Returns the loaded Class for a suite name.protected java.lang.String
processArguments(java.lang.String[] args)
Processes the command line arguments and returns the name of the suite class to run or nullprotected abstract void
runFailed(java.lang.String message)
Override to define how to handle a failed loading of a test suite.static void
savePreferences()
void
setLoading(boolean enable)
Sets the loading behaviour of the test runnerstatic void
setPreference(java.lang.String key, java.lang.String value)
protected static void
setPreferences(java.util.Properties preferences)
protected static boolean
showStackRaw()
void
startTest(Test test)
A test started.abstract void
testEnded(java.lang.String testName)
abstract void
testFailed(int status, Test test, java.lang.Throwable e)
abstract void
testStarted(java.lang.String testName)
static java.lang.String
truncate(java.lang.String s)
Truncates a String to the maximum length.protected boolean
useReloadingTestSuiteLoader()
-
-
-
Field Detail
-
SUITE_METHODNAME
public static final java.lang.String SUITE_METHODNAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BaseTestRunner
public BaseTestRunner()
-
-
Method Detail
-
startTest
public void startTest(Test test)
Description copied from interface:TestListener
A test started.- Specified by:
startTest
in interfaceTestListener
-
setPreferences
protected static void setPreferences(java.util.Properties preferences)
-
getPreferences
protected static java.util.Properties getPreferences()
-
savePreferences
public static void savePreferences() throws java.io.IOException
- Throws:
java.io.IOException
-
setPreference
public static void setPreference(java.lang.String key, java.lang.String value)
-
endTest
public void endTest(Test test)
Description copied from interface:TestListener
A test ended.- Specified by:
endTest
in interfaceTestListener
-
addError
public void addError(Test test, java.lang.Throwable e)
Description copied from interface:TestListener
An error occurred.- Specified by:
addError
in interfaceTestListener
-
addFailure
public void addFailure(Test test, AssertionFailedError e)
Description copied from interface:TestListener
A failure occurred.- Specified by:
addFailure
in interfaceTestListener
-
testStarted
public abstract void testStarted(java.lang.String testName)
-
testEnded
public abstract void testEnded(java.lang.String testName)
-
testFailed
public abstract void testFailed(int status, Test test, java.lang.Throwable e)
-
getTest
public Test getTest(java.lang.String suiteClassName)
Returns the Test corresponding to the given suite. This is a template method, subclasses override runFailed(), clearStatus().
-
elapsedTimeAsString
public java.lang.String elapsedTimeAsString(long runTime)
Returns the formatted string of the elapsed time.
-
processArguments
protected java.lang.String processArguments(java.lang.String[] args)
Processes the command line arguments and returns the name of the suite class to run or null
-
setLoading
public void setLoading(boolean enable)
Sets the loading behaviour of the test runner
-
extractClassName
public java.lang.String extractClassName(java.lang.String className)
Extract the class name from a String in VA/Java style
-
truncate
public static java.lang.String truncate(java.lang.String s)
Truncates a String to the maximum length.
-
runFailed
protected abstract void runFailed(java.lang.String message)
Override to define how to handle a failed loading of a test suite.
-
loadSuiteClass
protected java.lang.Class<?> loadSuiteClass(java.lang.String suiteClassName) throws java.lang.ClassNotFoundException
Returns the loaded Class for a suite name.- Throws:
java.lang.ClassNotFoundException
-
clearStatus
protected void clearStatus()
Clears the status message.
-
useReloadingTestSuiteLoader
protected boolean useReloadingTestSuiteLoader()
-
getPreference
public static java.lang.String getPreference(java.lang.String key)
-
getPreference
public static int getPreference(java.lang.String key, int dflt)
-
getFilteredTrace
public static java.lang.String getFilteredTrace(java.lang.Throwable e)
Returns a filtered stack trace
-
getFilteredTrace
public static java.lang.String getFilteredTrace(java.lang.String stack)
Filters stack frames from internal JUnit classes
-
showStackRaw
protected static boolean showStackRaw()
-
-