Build 1.0_r1(from source)

junit.runner
Class BaseTestRunner

java.lang.Object
  extended by junit.runner.BaseTestRunner
All Implemented Interfaces:
TestListener
Direct Known Subclasses:
AndroidTestRunner, TestRunner

public abstract class BaseTestRunner
extends Object
implements TestListener

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


Field Summary
(package private) static boolean fgFilterStack
           
(package private) static int fgMaxMessageLength
           
(package private)  boolean fLoading
           
static String SUITE_METHODNAME
           
 
Constructor Summary
BaseTestRunner()
           
 
Method Summary
 void addError(Test test, Throwable t)
          An error occurred.
 void addFailure(Test test, AssertionFailedError t)
          A failure occurred.
protected  void clearStatus()
          Clears the status message.
 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
(package private) static boolean filterLine(String line)
           
static String getFilteredTrace(String stack)
          Filters stack frames from internal JUnit classes
static String getFilteredTrace(Throwable t)
          Returns a filtered stack trace
 TestSuiteLoader getLoader()
          Returns the loader to be used.
static String getPreference(String key)
           
static int getPreference(String key, int dflt)
           
protected static Properties getPreferences()
           
 Test getTest(String suiteClassName)
          Returns the Test corresponding to the given suite.
static boolean inVAJava()
           
protected  Class loadSuiteClass(String suiteClassName)
          Returns the loaded Class for a suite name.
protected  String processArguments(String[] args)
          Processes the command line arguments and returns the name of the suite class to run or null
protected abstract  void runFailed(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 runner
 void setPreference(String key, String value)
           
protected static void setPreferences(Properties preferences)
           
protected static boolean showStackRaw()
           
 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  boolean useReloadingTestSuiteLoader()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUITE_METHODNAME

public static final String SUITE_METHODNAME
See Also:
Constant Field Values

fgMaxMessageLength

static int fgMaxMessageLength

fgFilterStack

static boolean fgFilterStack

fLoading

boolean fLoading
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 interface TestListener

setPreferences

protected static void setPreferences(Properties preferences)

getPreferences

protected static Properties getPreferences()

savePreferences

public static void savePreferences()
                            throws IOException
Throws:
IOException

setPreference

public void setPreference(String key,
                          String value)

endTest

public void endTest(Test test)
Description copied from interface: TestListener
A test ended.

Specified by:
endTest in interface TestListener

addError

public void addError(Test test,
                     Throwable t)
Description copied from interface: TestListener
An error occurred.

Specified by:
addError in interface TestListener

addFailure

public void addFailure(Test test,
                       AssertionFailedError t)
Description copied from interface: TestListener
A failure occurred.

Specified by:
addFailure in interface TestListener

testStarted

public abstract void testStarted(String testName)

testEnded

public abstract void testEnded(String testName)

testFailed

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

getTest

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


elapsedTimeAsString

public String elapsedTimeAsString(long runTime)
Returns the formatted string of the elapsed time.


processArguments

protected String processArguments(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 String extractClassName(String className)
Extract the class name from a String


truncate

public static String truncate(String s)
Truncates a String to the maximum length.


runFailed

protected abstract void runFailed(String message)
Override to define how to handle a failed loading of a test suite.


loadSuiteClass

protected Class loadSuiteClass(String suiteClassName)
                        throws ClassNotFoundException
Returns the loaded Class for a suite name.

Throws:
ClassNotFoundException

clearStatus

protected void clearStatus()
Clears the status message.


getLoader

public TestSuiteLoader getLoader()
Returns the loader to be used.


useReloadingTestSuiteLoader

protected boolean useReloadingTestSuiteLoader()

getPreference

public static String getPreference(String key)

getPreference

public static int getPreference(String key,
                                int dflt)

inVAJava

public static boolean inVAJava()

getFilteredTrace

public static String getFilteredTrace(Throwable t)
Returns a filtered stack trace


getFilteredTrace

public static String getFilteredTrace(String stack)
Filters stack frames from internal JUnit classes


showStackRaw

protected static boolean showStackRaw()

filterLine

static boolean filterLine(String line)

Build 1.0_r1(from source)

Please submit a feedback, bug or feature