Class TestRuleAdapter
java.lang.Object
com.carrotsearch.randomizedtesting.rules.TestRuleAdapter
- All Implemented Interfaces:
org.junit.rules.TestRule
- Direct Known Subclasses:
RequireAssertionsRule
An abstract
TestRule
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.-
Constructor Summary
Constructors -
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.org.junit.runners.model.Statement
apply
(org.junit.runners.model.Statement s, org.junit.runner.Description d) protected void
before()
Always called before the delegateStatement
.
-
Constructor Details
-
TestRuleAdapter
public TestRuleAdapter()
-
-
Method Details
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement s, org.junit.runner.Description d) - Specified by:
apply
in interfaceorg.junit.rules.TestRule
-
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
-