类 DirtiesContextBeforeModesTestExecutionListener
- java.lang.Object
- org.springframework.test.context.support.AbstractTestExecutionListener
- org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener
- org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener
- 所有已实现的接口:
Ordered
,TestExecutionListener
public class DirtiesContextBeforeModesTestExecutionListener extends AbstractDirtiesContextTestExecutionListener
TestExecutionListener
which provides support for marking theApplicationContext
associated with a test as dirty for both test classes and test methods annotated with the@DirtiesContext
annotation.This listener supports test methods with the method mode set to
BEFORE_METHOD
and test classes with the class mode set toBEFORE_EACH_TEST_METHOD
orBEFORE_CLASS
. For support for AFTER modes, seeDirtiesContextTestExecutionListener
.When merging
TestExecutionListeners
with the defaults, this listener will automatically be ordered before theDependencyInjectionTestExecutionListener
; otherwise, this listener must be manually configured to execute before theDependencyInjectionTestExecutionListener
.- 从以下版本开始:
- 4.2
- 作者:
- Sam Brannen
- 另请参阅:
DirtiesContext
,DirtiesContextTestExecutionListener
字段概要
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
beforeTestClass(TestContext testContext)
If the test class of the supplied test context is annotated with@DirtiesContext
and the class mode is set toBEFORE_CLASS
, the application context of the test context will be marked as dirty, and theREINJECT_DEPENDENCIES_ATTRIBUTE
in the test context will be set totrue
.void
beforeTestMethod(TestContext testContext)
If the current test method of the supplied test context is annotated with@DirtiesContext
and the method mode is set toBEFORE_METHOD
, or if the test class is annotated with@DirtiesContext
and the class mode is set toBEFORE_EACH_TEST_METHOD
, the application context of the test context will be marked as dirty and theREINJECT_DEPENDENCIES_ATTRIBUTE
in the test context will be set totrue
.int
getOrder()
Returns1500
.从类继承的方法 org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener
beforeOrAfterTestClass, beforeOrAfterTestMethod, dirtyContext
从类继承的方法 org.springframework.test.context.support.AbstractTestExecutionListener
afterTestClass, afterTestMethod, prepareTestInstance
构造器详细资料
DirtiesContextBeforeModesTestExecutionListener
public DirtiesContextBeforeModesTestExecutionListener()
方法详细资料
getOrder
public final int getOrder()
Returns1500
.- 指定者:
getOrder
在接口中Ordered
- 指定者:
getOrder
在类中AbstractDirtiesContextTestExecutionListener
- 返回:
- the order value
- 另请参阅:
Ordered.HIGHEST_PRECEDENCE
,Ordered.LOWEST_PRECEDENCE
beforeTestClass
public void beforeTestClass(TestContext testContext) throws Exception
If the test class of the supplied test context is annotated with@DirtiesContext
and the class mode is set toBEFORE_CLASS
, the application context of the test context will be marked as dirty, and theREINJECT_DEPENDENCIES_ATTRIBUTE
in the test context will be set totrue
.- 指定者:
beforeTestClass
在接口中TestExecutionListener
- 覆盖:
beforeTestClass
在类中AbstractTestExecutionListener
- 参数:
testContext
- the test context for the test; nevernull
- 抛出:
Exception
- allows any exception to propagate
beforeTestMethod
public void beforeTestMethod(TestContext testContext) throws Exception
If the current test method of the supplied test context is annotated with@DirtiesContext
and the method mode is set toBEFORE_METHOD
, or if the test class is annotated with@DirtiesContext
and the class mode is set toBEFORE_EACH_TEST_METHOD
, the application context of the test context will be marked as dirty and theREINJECT_DEPENDENCIES_ATTRIBUTE
in the test context will be set totrue
.- 指定者:
beforeTestMethod
在接口中TestExecutionListener
- 覆盖:
beforeTestMethod
在类中AbstractTestExecutionListener
- 参数:
testContext
- the test context in which the test method will be executed; nevernull
- 抛出:
Exception
- allows any exception to propagate