Class SpringIntegrationMethodRule

java.lang.Object
net.serenitybdd.junit.spring.integration.SpringIntegrationMethodRule
All Implemented Interfaces:
org.junit.rules.MethodRule

public class SpringIntegrationMethodRule
extends java.lang.Object
implements org.junit.rules.MethodRule
A TestRule to be used with @Rule to run the @Before and @After modifiers that are part of SpringJUnit4ClassRunner.
Author:
[email protected]
  • Constructor Summary

    Constructors 
    Constructor Description
    SpringIntegrationMethodRule()  
  • Method Summary

    Modifier and Type Method Description
    protected org.junit.runners.model.Statement apply​(org.junit.runners.model.Statement next, java.lang.Class<?> testClass, java.lang.Object testInstance, net.serenitybdd.junit.spring.integration.SpringIntegrationRuleBase.StatementWrapper beforeWrapper, net.serenitybdd.junit.spring.integration.SpringIntegrationRuleBase.StatementWrapper afterWrapper)
    Wraps a before and after statement around the supplied statement, possibly preparing the test instance first.
    org.junit.runners.model.Statement apply​(org.junit.runners.model.Statement base, org.junit.runners.model.FrameworkMethod frameworkMethod, java.lang.Object target)
    Wraps RunBeforeTestMethodCallbacks and RunAfterTestMethodCallbacks around the provided statement.
    static org.springframework.test.context.TestContextManager createTestContextManager​(java.lang.Class<?> testClass)
    Creates a test context manager.
    org.springframework.test.context.TestContextManager getTestContextManager​(java.lang.Class<?> testClass)
    Gets the test context manager, creating it if it doesn't exist.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SpringIntegrationMethodRule

      public SpringIntegrationMethodRule()
  • Method Details

    • apply

      public org.junit.runners.model.Statement apply​(org.junit.runners.model.Statement base, org.junit.runners.model.FrameworkMethod frameworkMethod, java.lang.Object target)
      Wraps RunBeforeTestMethodCallbacks and RunAfterTestMethodCallbacks around the provided statement.
      Specified by:
      apply in interface org.junit.rules.MethodRule
      Parameters:
      base - The base statement
      frameworkMethod - Information about the test method being run.
      target - The instance of the test class being run.
      Returns:
      The wrapped statement.
    • createTestContextManager

      public static org.springframework.test.context.TestContextManager createTestContextManager​(java.lang.Class<?> testClass)
      Creates a test context manager.
      Parameters:
      testClass - The test class to create the test context manager for.
      Returns:
      The new test context manager.
    • getTestContextManager

      public org.springframework.test.context.TestContextManager getTestContextManager​(java.lang.Class<?> testClass)
      Gets the test context manager, creating it if it doesn't exist.
      Parameters:
      testClass - The test class to create the test context manager for, if it doesn't exist.
      Returns:
      The test context manager.
    • apply

      protected org.junit.runners.model.Statement apply​(org.junit.runners.model.Statement next, java.lang.Class<?> testClass, java.lang.Object testInstance, net.serenitybdd.junit.spring.integration.SpringIntegrationRuleBase.StatementWrapper beforeWrapper, net.serenitybdd.junit.spring.integration.SpringIntegrationRuleBase.StatementWrapper afterWrapper)
      Wraps a before and after statement around the supplied statement, possibly preparing the test instance first.
      Parameters:
      next - The next statement.
      testClass - The class being tested.
      testInstance - The instance of the class being tested.
      beforeWrapper - The before wrapper.
      afterWrapper - The after wrapper.
      Returns:
      The new, wrapped statement.