Package de.hybris.platform.testframework
Class ChainingRunNotifierWrapper
java.lang.Object
org.junit.runner.notification.RunNotifier
de.hybris.platform.testframework.ChainingRunNotifierWrapper
public class ChainingRunNotifierWrapper
extends org.junit.runner.notification.RunNotifier
Wraps a
RunNotifier to extend the listener concept to act like a chain in meaning of having revert order on
test finalizing. For this the listener added will not be passed to the wrapped instance to avoid calling them twice,
so the wrapped instance holds only the instances assigned before wrapping. As the BlockJUnit4ClassRunner is
used differently in environments there is no chance to intercept the RunNotifier creation, so this wrapper
can be used first at entry of ParentRunner.run(RunNotifier) method. Unfortunately the firing of
events for a complete test run are done outside. With that this events will not be delegatet to the wrapper instance
in general as they will be called separately outside of run method.-
Constructor Summary
ConstructorsConstructorDescriptionChainingRunNotifierWrapper(org.junit.runner.notification.RunNotifier delegate) Creates a new notifier using passed notifier as delegate.ChainingRunNotifierWrapper(org.junit.runner.notification.RunNotifier delegate, Class<?> classUnderTest) Creates a new notifier using passed notifier as delegate. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFirstListener(org.junit.runner.notification.RunListener listener) Adds the listener as first listener to this notifier, not to wrapped one.voidaddListener(org.junit.runner.notification.RunListener listener) Adds the listener to this notifier, will not be added to wrapped one.voidfireTestAssumptionFailed(org.junit.runner.notification.Failure failure) Delegates to wrapper first, then callsRunListener.testAssumptionFailure(Failure)for all listeners in normal order.voidfireTestFailure(org.junit.runner.notification.Failure failure) Delegates to wrapper first, then callsRunListener.testFailure(Failure)for all listeners in reverse order.voidfireTestFinished(org.junit.runner.Description description) CallsRunListener.testFinished(Description)for all listeners in reversed order, afterwards it calls wrapper implementation.voidfireTestIgnored(org.junit.runner.Description description) Delegates to wrapper first, then callsRunListener.testIgnored(Description)for all listeners in normal order.voidfireTestRunFinished(org.junit.runner.Result result) CallsRunListener.testRunFinished(Result)for all listeners in reverse order.voidfireTestRunStarted(org.junit.runner.Description description) CallsRunListener.testRunStarted(Description)for all listeners in normal order.voidfireTestStarted(org.junit.runner.Description description) Delegates to wrapper first, then callsRunListener.testStarted(Description)for all listeners in normal order.voidSimply delegates to wrapped runner.protected org.junit.runner.DescriptionrecreateTestDescription(org.junit.runner.Description description) voidRemoves all listeners for this runner.voidremoveListener(org.junit.runner.notification.RunListener listener) Removes the listener from wrapped notifier and this notifier.Methods inherited from class org.junit.runner.notification.RunNotifier
fireTestSuiteFinished, fireTestSuiteStarted
-
Constructor Details
-
ChainingRunNotifierWrapper
public ChainingRunNotifierWrapper(org.junit.runner.notification.RunNotifier delegate) Creates a new notifier using passed notifier as delegate. -
ChainingRunNotifierWrapper
public ChainingRunNotifierWrapper(org.junit.runner.notification.RunNotifier delegate, Class<?> classUnderTest) Creates a new notifier using passed notifier as delegate.
-
-
Method Details
-
addFirstListener
public void addFirstListener(org.junit.runner.notification.RunListener listener) Adds the listener as first listener to this notifier, not to wrapped one.- Overrides:
addFirstListenerin classorg.junit.runner.notification.RunNotifier
-
addListener
public void addListener(org.junit.runner.notification.RunListener listener) Adds the listener to this notifier, will not be added to wrapped one.- Overrides:
addListenerin classorg.junit.runner.notification.RunNotifier
-
removeListener
public void removeListener(org.junit.runner.notification.RunListener listener) Removes the listener from wrapped notifier and this notifier.- Overrides:
removeListenerin classorg.junit.runner.notification.RunNotifier
-
fireTestRunStarted
public void fireTestRunStarted(org.junit.runner.Description description) CallsRunListener.testRunStarted(Description)for all listeners in normal order. No call to wrapper will be done as listeners of wrapper will be called outside of run method of ClassRunner.- Overrides:
fireTestRunStartedin classorg.junit.runner.notification.RunNotifier
-
fireTestRunFinished
public void fireTestRunFinished(org.junit.runner.Result result) CallsRunListener.testRunFinished(Result)for all listeners in reverse order. No call to wrapper will be done as listeners of wrapper will are called already outside of run method of ClassRunner.- Overrides:
fireTestRunFinishedin classorg.junit.runner.notification.RunNotifier
-
fireTestStarted
public void fireTestStarted(org.junit.runner.Description description) throws org.junit.runner.notification.StoppedByUserException Delegates to wrapper first, then callsRunListener.testStarted(Description)for all listeners in normal order.- Overrides:
fireTestStartedin classorg.junit.runner.notification.RunNotifier- Throws:
org.junit.runner.notification.StoppedByUserException
-
fireTestFailure
public void fireTestFailure(org.junit.runner.notification.Failure failure) Delegates to wrapper first, then callsRunListener.testFailure(Failure)for all listeners in reverse order.- Overrides:
fireTestFailurein classorg.junit.runner.notification.RunNotifier
-
fireTestAssumptionFailed
public void fireTestAssumptionFailed(org.junit.runner.notification.Failure failure) Delegates to wrapper first, then callsRunListener.testAssumptionFailure(Failure)for all listeners in normal order.- Overrides:
fireTestAssumptionFailedin classorg.junit.runner.notification.RunNotifier
-
fireTestIgnored
public void fireTestIgnored(org.junit.runner.Description description) Delegates to wrapper first, then callsRunListener.testIgnored(Description)for all listeners in normal order.- Overrides:
fireTestIgnoredin classorg.junit.runner.notification.RunNotifier
-
fireTestFinished
public void fireTestFinished(org.junit.runner.Description description) CallsRunListener.testFinished(Description)for all listeners in reversed order, afterwards it calls wrapper implementation.- Overrides:
fireTestFinishedin classorg.junit.runner.notification.RunNotifier
-
recreateTestDescription
protected org.junit.runner.Description recreateTestDescription(org.junit.runner.Description description) -
pleaseStop
public void pleaseStop()Simply delegates to wrapped runner.- Overrides:
pleaseStopin classorg.junit.runner.notification.RunNotifier
-
removeAllListeners
public void removeAllListeners()Removes all listeners for this runner.
-