public interface TestListenerRule extends TestRule
The purpose is here to provide an interface that can be implemented by rule implementor to do action, before, after and on some condition.
Rule implementer should implements this interface and then implement the required methods (which are do-nothing method by default). The order of execution is the following :
onStart(TestContext) is executed.onFailure(TestContext, AssertionError) in case of test failure.onError(TestContext, Throwable) in case of test error.onAssumptionSkip(TestContext, AssumptionError) in case of test
skip.onEnd(TestContext) is executed.ExternalResource rule implements this interface to provide simple
use case (action before and always after test).ExternalResource| Modifier and Type | Method and Description |
|---|---|
default Statement<TestContext<Object>,Throwable> |
computeStatement(Statement<TestContext<Object>,Throwable> inner)
The default implementation of test rule.
|
default void |
onAssumptionSkip(TestContext<Object> context,
AssumptionError error)
Method used when an assumption error happened.
|
default void |
onEnd(TestContext<Object> context)
Method used at the end of the test.
|
default void |
onError(TestContext<Object> context,
Throwable error)
Method used when an error happened.
|
default void |
onFailure(TestContext<Object> context,
AssertionError af)
Method used when a failure happened.
|
default void |
onStart(TestContext<Object> context)
Method used at the start of the test.
|
default void onStart(TestContext<Object> context)
Default implementation is to do nothing.
context - the test contextdefault void onFailure(TestContext<Object> context, AssertionError af)
Default implementation is to do nothing.
context - the test contextaf - the failuredefault void onError(TestContext<Object> context, Throwable error)
Default implementation is to do nothing.
context - the test contexterror - the errordefault void onAssumptionSkip(TestContext<Object> context, AssumptionError error)
Default implementation is to do nothing.
context - the test contexterror - the assumption errordefault void onEnd(TestContext<Object> context)
Default implementation is to do nothing.
context - the test contextdefault Statement<TestContext<Object>,Throwable> computeStatement(Statement<TestContext<Object>,Throwable> inner)
TestRuleThe goal of this method is to compute another test statement that will be the one to be runned.
computeStatement in interface TestRuleinner - the inner statementCopyright © 2014. All rights reserved.