Package ej.junit
Class AbstractTestWrapper
- java.lang.Object
-
- ej.junit.AbstractTestWrapper
-
- All Implemented Interfaces:
TestWrapper
public abstract class AbstractTestWrapper extends Object implements TestWrapper
Base class used by generated wrappers. It is where the test execution happens. Implements theTestWrapperinterface so it can be called by another application.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanfailedprotected Objecttestprotected Class<?>testClassprotected StringtestClassNameprotected TestListenertestListenerprotected StringtestMethodprotected longtestMethodStart
-
Constructor Summary
Constructors Constructor Description AbstractTestWrapper(Class<?> testClass)Creates a wrapper instance for the specified test class.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringgetTestClass()protected voidreportError(Throwable error)Called by generated wrappers to report an error.protected voidreportFailure(AssertionError error)Called by generated wrappers to report a failure.protected voidreportSkip(String message)Called by generated wrappers to report that a test was skipped.protected voidreportTestEnd()booleanrun(TestListener listener)protected abstract voidrunAfterClassMethods()To be implemented by generated subclasses, triggers the execution of methods tagged withAfterClassprotected abstract voidrunAfterMethods()To be implemented by generated subclasses, triggers the execution of methods tagged withAfterprotected abstract voidrunBeforeClassMethods()To be implemented by generated subclasses, triggers the execution of methods tagged withBeforeClassprotected abstract voidrunBeforeMethods()To be implemented by generated subclasses, triggers the execution of methods tagged withBeforeprotected abstract voidrunTestMethods()To be implemented by generated subclasses, triggers the execution of test methods tagged withTestprotected voidtestFinalize()Called by generated subclasses to trigger test finalization.protected voidtestFinalize(boolean success)Called by generated subclasses to trigger test finalization.protected booleantestInitialize(String testMethodName)Called by generated subclasses to trigger test initialization, by instantiating the test class and calling theBeforemethods.
-
-
-
Field Detail
-
testClass
protected final Class<?> testClass
-
testClassName
protected final String testClassName
-
failed
protected boolean failed
-
testMethod
protected String testMethod
-
testMethodStart
protected long testMethodStart
-
test
protected Object test
-
testListener
protected TestListener testListener
-
-
Constructor Detail
-
AbstractTestWrapper
public AbstractTestWrapper(Class<?> testClass)
Creates a wrapper instance for the specified test class.Queries and store the class name, so clients of the wrappers can look them up by name if necessary.
- Parameters:
testClass- the test class to instantiate.
-
-
Method Detail
-
reportError
protected void reportError(Throwable error)
Called by generated wrappers to report an error.If a listener has been passed to
run(TestListener), then theTestListener.onError(String, String, String)is called.- Parameters:
error- theThrowablethat caused the error.- See Also:
run(TestListener)
-
reportFailure
protected void reportFailure(AssertionError error)
Called by generated wrappers to report a failure.If a listener has been passed to
run(TestListener), then theTestListener.onFailure(String, String, String)is called.- Parameters:
error- theAssertionErrorthat caused the failure.- See Also:
run(TestListener)
-
reportSkip
protected void reportSkip(String message)
Called by generated wrappers to report that a test was skipped.If a listener has been passed to
run(TestListener), then theTestListener.onSkip(String)is called.- Parameters:
message- the message associated with the test skip- See Also:
run(TestListener)
-
reportTestEnd
protected void reportTestEnd()
-
runBeforeClassMethods
protected abstract void runBeforeClassMethods() throws ExceptionTo be implemented by generated subclasses, triggers the execution of methods tagged withBeforeClass- Throws:
Exception- if one of theBeforeClassmethods throws one.
-
runAfterClassMethods
protected abstract void runAfterClassMethods() throws ExceptionTo be implemented by generated subclasses, triggers the execution of methods tagged withAfterClass- Throws:
Exception- if one of theAfterClassmethods throws one.
-
runBeforeMethods
protected abstract void runBeforeMethods() throws ExceptionTo be implemented by generated subclasses, triggers the execution of methods tagged withBefore
-
runAfterMethods
protected abstract void runAfterMethods() throws ExceptionTo be implemented by generated subclasses, triggers the execution of methods tagged withAfter- Throws:
Exception- if one of theBeforeClassmethods throws one.
-
runTestMethods
protected abstract void runTestMethods()
To be implemented by generated subclasses, triggers the execution of test methods tagged withTest
-
testInitialize
protected final boolean testInitialize(String testMethodName)
Called by generated subclasses to trigger test initialization, by instantiating the test class and calling theBeforemethods.- Parameters:
testMethodName- the name of the test method to initialize.- Returns:
- true if the operation succeeded and the test can continue, false otherwise.
-
testFinalize
protected final void testFinalize(boolean success)
Called by generated subclasses to trigger test finalization. Reports the test end and calls the After methods. This method only exists for backward compatibility with JUnit before 1.10.0.- Parameters:
success- is ignored
-
testFinalize
protected final void testFinalize()
Called by generated subclasses to trigger test finalization. Reports the test end and calls the After methods.
-
getTestClass
public String getTestClass()
- Specified by:
getTestClassin interfaceTestWrapper
-
run
public boolean run(TestListener listener)
- Specified by:
runin interfaceTestWrapper
-
-