类 DirtiesContextTestExecutionListener
- java.lang.Object
- org.springframework.test.context.support.AbstractTestExecutionListener
- org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener
- org.springframework.test.context.support.DirtiesContextTestExecutionListener
- 所有已实现的接口:
Ordered
,TestExecutionListener
public class DirtiesContextTestExecutionListener 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
AFTER_METHOD
and test classes with the class mode set toAFTER_EACH_TEST_METHOD
orAFTER_CLASS
. For support for BEFORE modes, seeDirtiesContextBeforeModesTestExecutionListener
.When merging
TestExecutionListeners
with the defaults, this listener will automatically be ordered after theDependencyInjectionTestExecutionListener
; otherwise, this listener must be manually configured to execute after theDependencyInjectionTestExecutionListener
.- 从以下版本开始:
- 2.5
- 作者:
- Sam Brannen
- 另请参阅:
DirtiesContext
,DirtiesContextBeforeModesTestExecutionListener
字段概要
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 DirtiesContextTestExecutionListener()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterTestClass(TestContext testContext)
If the test class of the supplied test context is annotated with@DirtiesContext
and the class mode is set toAFTER_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
afterTestMethod(TestContext testContext)
If the current test method of the supplied test context is annotated with@DirtiesContext
and the method mode is set toAFTER_METHOD
, or if the test class is annotated with@DirtiesContext
and the class mode is set toAFTER_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()
Returns3000
.从类继承的方法 org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener
beforeOrAfterTestClass, beforeOrAfterTestMethod, dirtyContext
从类继承的方法 org.springframework.test.context.support.AbstractTestExecutionListener
afterTestExecution, beforeTestClass, beforeTestExecution, beforeTestMethod, prepareTestInstance
构造器详细资料
DirtiesContextTestExecutionListener
public DirtiesContextTestExecutionListener()
方法详细资料
getOrder
public final int getOrder()
Returns3000
.- 指定者:
getOrder
在接口中Ordered
- 指定者:
getOrder
在类中AbstractDirtiesContextTestExecutionListener
- 返回:
- the order value
- 另请参阅:
Ordered.HIGHEST_PRECEDENCE
,Ordered.LOWEST_PRECEDENCE
afterTestMethod
public void afterTestMethod(TestContext testContext) throws Exception
If the current test method of the supplied test context is annotated with@DirtiesContext
and the method mode is set toAFTER_METHOD
, or if the test class is annotated with@DirtiesContext
and the class mode is set toAFTER_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
.- 指定者:
afterTestMethod
在接口中TestExecutionListener
- 覆盖:
afterTestMethod
在类中AbstractTestExecutionListener
- 参数:
testContext
- the test context in which the test method was executed; nevernull
- 抛出:
Exception
- allows any exception to propagate- 另请参阅:
TestExecutionListener.beforeTestMethod(org.springframework.test.context.TestContext)
,TestExecutionListener.beforeTestExecution(org.springframework.test.context.TestContext)
,TestExecutionListener.afterTestExecution(org.springframework.test.context.TestContext)
afterTestClass
public void afterTestClass(TestContext testContext) throws Exception
If the test class of the supplied test context is annotated with@DirtiesContext
and the class mode is set toAFTER_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
.- 指定者:
afterTestClass
在接口中TestExecutionListener
- 覆盖:
afterTestClass
在类中AbstractTestExecutionListener
- 参数:
testContext
- the test context for the test; nevernull
- 抛出:
Exception
- allows any exception to propagate