org.springframework.test.context.junit4.statements

Class RunAfterTestMethodCallbacks

  • java.lang.Object
    • org.junit.runners.model.Statement
      • org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks


  • public class RunAfterTestMethodCallbacks
    extends org.junit.runners.model.Statement
    RunAfterTestMethodCallbacks is a custom JUnit Statement which allows the Spring TestContext Framework to be plugged into the JUnit execution chain by calling afterTestMethod() on the supplied TestContextManager.

    NOTE: This class requires JUnit 4.9 or higher.

    Since:
    3.0
    Author:
    Sam Brannen
    See Also:
    evaluate(), RunBeforeTestMethodCallbacks
    • Constructor Summary

      Constructors 
      Constructor and Description
      RunAfterTestMethodCallbacks(org.junit.runners.model.Statement next, java.lang.Object testInstance, java.lang.reflect.Method testMethod, TestContextManager testContextManager)
      Construct a new RunAfterTestMethodCallbacks statement.
    • Constructor Detail

      • RunAfterTestMethodCallbacks

        public RunAfterTestMethodCallbacks(org.junit.runners.model.Statement next,
                                           java.lang.Object testInstance,
                                           java.lang.reflect.Method testMethod,
                                           TestContextManager testContextManager)
        Construct a new RunAfterTestMethodCallbacks statement.
        Parameters:
        next - the next Statement in the execution chain
        testInstance - the current test instance (never null)
        testMethod - the test method which has just been executed on the test instance
        testContextManager - the TestContextManager upon which to call afterTestMethod()
    • Method Detail

      • evaluate

        public void evaluate()
                      throws java.lang.Throwable
        Evaluate the next Statement in the execution chain (typically an instance of RunAfters), catching any exceptions thrown, and then invoke TestContextManager.afterTestMethod(Object, Method, Throwable) supplying the first caught exception (if any).

        If the invocation of afterTestMethod() throws an exception, that exception will also be tracked. Multiple exceptions will be combined into a MultipleFailureException.

        Specified by:
        evaluate in class org.junit.runners.model.Statement
        Throws:
        java.lang.Throwable