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 abstractStatement
that guarantees the execution ofafterAlways(java.util.List<java.lang.Throwable>)
even if an exception has been thrown from delegateStatement
. This is much likeAfterClass
orAfter
annotations but can be used withRuleChain
to guarantee the order of execution.
-
-
Field Summary
Fields Modifier and Type Field Description private org.junit.runners.model.Statement
delegate
-
Constructor Summary
Constructors Modifier Constructor Description protected
StatementAdapter(org.junit.runners.model.Statement delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
afterAlways(java.util.List<java.lang.Throwable> errors)
Always called after the delegateStatement
, even if an exception (or assumption failure) occurs.protected void
afterIfSuccessful()
Called only if the delegateStatement
returned successfully.protected void
before()
Always called before the delegateStatement
.void
evaluate()
-
-
-
Method Detail
-
evaluate
public final void evaluate() throws java.lang.Throwable
- Specified by:
evaluate
in classorg.junit.runners.model.Statement
- Throws:
java.lang.Throwable
-
before
protected void before() throws java.lang.Throwable
Always called before the delegateStatement
.- Throws:
java.lang.Throwable
-
afterAlways
protected void afterAlways(java.util.List<java.lang.Throwable> errors) throws java.lang.Throwable
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:
java.lang.Throwable
-
afterIfSuccessful
protected void afterIfSuccessful() throws java.lang.Throwable
Called only if the delegateStatement
returned successfully.- Throws:
java.lang.Throwable
-
-