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
    Modifier and Type
    Field
    Description
    private final org.junit.runners.model.Statement
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    StatementAdapter(org.junit.runners.model.Statement delegate)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Always called after the delegate Statement, even if an exception (or assumption failure) occurs.
    protected void
    Called only if the delegate Statement returned successfully.
    protected void
    Always called before the delegate Statement.
    final void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public final void evaluate() throws Throwable
      Specified by:
      evaluate in class org.junit.runners.model.Statement
      Throws:
      Throwable
    • before

      protected void before() throws Throwable
      Always called before the delegate Statement.
      Throws:
      Throwable
    • afterAlways

      protected void afterAlways(List<Throwable> errors) throws Throwable
      Always called after the delegate Statement, even if an exception (or assumption failure) occurs. Any exceptions thrown from the body of this method will be chained using MultipleFailureException.
      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

      protected void afterIfSuccessful() throws Throwable
      Called only if the delegate Statement returned successfully.
      Throws:
      Throwable