Class StatementAdapter
java.lang.Object
org.junit.runners.model.Statement
com.carrotsearch.randomizedtesting.rules.StatementAdapter
public abstract class StatementAdapter
extends org.junit.runners.model.Statement
An abstract
Statement
that guarantees the execution of
afterAlways(java.util.List<java.lang.Throwable>)
even if an exception has been thrown from delegate
Statement
. This is much like AfterClass
or After
annotations but can be used with RuleChain
to guarantee the order of
execution.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
StatementAdapter
(org.junit.runners.model.Statement delegate) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
afterAlways
(List<Throwable> errors) Always called after the delegateStatement
, even if an exception (or assumption failure) occurs.protected void
Called only if the delegateStatement
returned successfully.protected void
before()
Always called before the delegateStatement
.final void
evaluate()
-
Field Details
-
delegate
private final org.junit.runners.model.Statement delegate
-
-
Constructor Details
-
StatementAdapter
protected StatementAdapter(org.junit.runners.model.Statement delegate)
-
-
Method Details
-
evaluate
- Specified by:
evaluate
in classorg.junit.runners.model.Statement
- Throws:
Throwable
-
before
Always called before the delegateStatement
.- Throws:
Throwable
-
afterAlways
Always called after the delegateStatement
, even if an exception (or assumption failure) occurs. Any exceptions thrown from the body of this method will be chained usingMultipleFailureException
.- Parameters:
errors
- A list of errors received so far. The list is modifiable although should only be extended with new potential exceptions.- Throws:
Throwable
-
afterIfSuccessful
Called only if the delegateStatement
returned successfully.- Throws:
Throwable
-