Class TestRuleAdapter
- java.lang.Object
-
- com.carrotsearch.randomizedtesting.rules.TestRuleAdapter
-
- All Implemented Interfaces:
org.junit.rules.TestRule
- Direct Known Subclasses:
RequireAssertionsRule
public abstract class TestRuleAdapter extends java.lang.Object implements org.junit.rules.TestRuleAn abstractTestRulethat guarantees the execution ofafterAlways(java.util.List<java.lang.Throwable>)even if an exception has been thrown from delegateStatement. This is much likeAfterClassorAfterannotations but can be used withRuleChainto guarantee the order of execution.
-
-
Constructor Summary
Constructors Constructor Description TestRuleAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafterAlways(java.util.List<java.lang.Throwable> errors)Always called after the delegateStatement, even if an exception (or assumption failure) occurs.protected voidafterIfSuccessful()Called only if the delegateStatementreturned successfully.org.junit.runners.model.Statementapply(org.junit.runners.model.Statement s, org.junit.runner.Description d)protected voidbefore()Always called before the delegateStatement.
-
-
-
Method Detail
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement s, org.junit.runner.Description d)- Specified by:
applyin interfaceorg.junit.rules.TestRule
-
before
protected void before() throws java.lang.ThrowableAlways called before the delegateStatement.- Throws:
java.lang.Throwable
-
afterAlways
protected void afterAlways(java.util.List<java.lang.Throwable> errors) throws java.lang.ThrowableAlways 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.ThrowableCalled only if the delegateStatementreturned successfully.- Throws:
java.lang.Throwable
-
-