类 InfraMethodRule

java.lang.Object
cn.taketoday.test.context.junit4.rules.InfraMethodRule
所有已实现的接口:
org.junit.rules.MethodRule

public class InfraMethodRule extends Object implements org.junit.rules.MethodRule
ApplicationMethodRule is a custom JUnit 4 MethodRule that supports instance-level and method-level features of the TestContext Framework in standard JUnit tests by means of the TestContextManager and associated support classes and annotations.

In contrast to the JUnit4ClassRunner, Framework's rule-based JUnit support has the advantage that it is independent of any Runner and can therefore be combined with existing alternative runners like JUnit's Parameterized or third-party runners such as the MockitoJUnitRunner.

In order to achieve the same functionality as the JUnit4ClassRunner, however, a ApplicationMethodRule must be combined with a InfraClassRule, since ApplicationMethodRule only supports the instance-level and method-level features of the JUnit4ClassRunner.

Example Usage

 public class ExampleInfraIntegrationTest {

    @ClassRule
    public static final ApplicationClassRule applicationClassRule = new ApplicationClassRule();

    @Rule
    public final ApplicationMethodRule applicationMethodRule = new ApplicationMethodRule();

    // ...
 }

The following list constitutes all annotations currently supported directly or indirectly by ApplicationMethodRule. (Note that additional annotations may be supported by various TestExecutionListener or TestContextBootstrapper implementations.)

NOTE: this class requires JUnit 4.12 or higher.

WARNING: Due to the shortcomings of JUnit rules, the ApplicationMethodRule prepares the test instance before @Before lifecycle methods instead of immediately after instantiation of the test class. In addition, the ApplicationMethodRule does not support the beforeTestExecution() and afterTestExecution() callbacks of the TestExecutionListener API.

从以下版本开始:
4.0
作者:
Sam Brannen, Philippe Marschall
另请参阅:
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    private static final cn.taketoday.logging.Logger
     
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    org.junit.runners.model.Statement
    apply(org.junit.runners.model.Statement base, org.junit.runners.model.FrameworkMethod frameworkMethod, Object testInstance)
    Apply instance-level and method-level features of the TestContext Framework to the supplied base statement.
    private org.junit.runners.model.Statement
    withAfterTestMethodCallbacks(org.junit.runners.model.Statement next, Method testMethod, Object testInstance, TestContextManager testContextManager)
    Wrap the supplied Statement with a RunAfterTestMethodCallbacks statement.
    private org.junit.runners.model.Statement
    withBeforeTestMethodCallbacks(org.junit.runners.model.Statement next, Method testMethod, Object testInstance, TestContextManager testContextManager)
    Wrap the supplied Statement with a RunBeforeTestMethodCallbacks statement.
    private org.junit.runners.model.Statement
    withPotentialRepeat(org.junit.runners.model.Statement next, Method testMethod, Object testInstance)
    Wrap the supplied Statement with a RepeatTest statement.
    private org.junit.runners.model.Statement
    withPotentialTimeout(org.junit.runners.model.Statement next, Method testMethod, Object testInstance)
    Wrap the supplied Statement with a FailOnTimeout statement.
    private org.junit.runners.model.Statement
    withProfileValueCheck(org.junit.runners.model.Statement next, Method testMethod, Object testInstance)
    Wrap the supplied Statement with a ProfileValueChecker statement.
    private org.junit.runners.model.Statement
    withTestInstancePreparation(org.junit.runners.model.Statement next, Object testInstance, TestContextManager testContextManager)
    Wrap the supplied Statement with a RunPrepareTestInstanceCallbacks statement.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait