类 AbstractDirtiesContextTestExecutionListener
- java.lang.Object
- org.springframework.test.context.support.AbstractTestExecutionListener
- org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener
- 所有已实现的接口:
Ordered
,TestExecutionListener
public abstract class AbstractDirtiesContextTestExecutionListener extends AbstractTestExecutionListener
Abstract base class forTestExecutionListener
implementations that provide support for marking theApplicationContext
associated with a test as dirty for both test classes and test methods annotated with the@DirtiesContext
annotation.The core functionality for this class was extracted from
DirtiesContextTestExecutionListener
in Spring Framework 4.2.- 从以下版本开始:
- 4.2
- 作者:
- Sam Brannen, Juergen Hoeller
- 另请参阅:
DirtiesContext
字段概要
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 AbstractDirtiesContextTestExecutionListener()
方法概要
从类继承的方法 org.springframework.test.context.support.AbstractTestExecutionListener
afterTestClass, afterTestMethod, beforeTestClass, beforeTestMethod, prepareTestInstance
构造器详细资料
AbstractDirtiesContextTestExecutionListener
public AbstractDirtiesContextTestExecutionListener()
方法详细资料
getOrder
public abstract int getOrder()
从类复制的说明:AbstractTestExecutionListener
The default implementation returnsOrdered.LOWEST_PRECEDENCE
, thereby ensuring that custom listeners are ordered after default listeners supplied by the framework. Can be overridden by subclasses as necessary.- 指定者:
getOrder
在接口中Ordered
- 覆盖:
getOrder
在类中AbstractTestExecutionListener
- 返回:
- the order value
- 另请参阅:
Ordered.HIGHEST_PRECEDENCE
,Ordered.LOWEST_PRECEDENCE
dirtyContext
protected void dirtyContext(TestContext testContext, DirtiesContext.HierarchyMode hierarchyMode)
Mark the application context of the supplied test context as dirty and setREINJECT_DEPENDENCIES_ATTRIBUTE
in the test context totrue
.- 参数:
testContext
- the test context whose application context should be marked as dirtyhierarchyMode
- the context cache clearing mode to be applied if the context is part of a hierarchy; may benull
- 从以下版本开始:
- 3.2.2
beforeOrAfterTestMethod
protected void beforeOrAfterTestMethod(TestContext testContext, DirtiesContext.MethodMode requiredMethodMode, DirtiesContext.ClassMode requiredClassMode) throws Exception
Perform the actual work forAbstractTestExecutionListener.beforeTestMethod(org.springframework.test.context.TestContext)
andAbstractTestExecutionListener.afterTestMethod(org.springframework.test.context.TestContext)
by dirtying the context if appropriate (i.e., according to the required modes).- 参数:
testContext
- the test context whose application context should potentially be marked as dirty; nevernull
requiredMethodMode
- the method mode required for a context to be marked dirty in the current phase; nevernull
requiredClassMode
- the class mode required for a context to be marked dirty in the current phase; nevernull
- 抛出:
Exception
- allows any exception to propagate- 从以下版本开始:
- 4.2
- 另请参阅:
dirtyContext(org.springframework.test.context.TestContext, org.springframework.test.annotation.DirtiesContext.HierarchyMode)
beforeOrAfterTestClass
protected void beforeOrAfterTestClass(TestContext testContext, DirtiesContext.ClassMode requiredClassMode) throws Exception
Perform the actual work forAbstractTestExecutionListener.beforeTestClass(org.springframework.test.context.TestContext)
andAbstractTestExecutionListener.afterTestClass(org.springframework.test.context.TestContext)
by dirtying the context if appropriate (i.e., according to the required mode).- 参数:
testContext
- the test context whose application context should potentially be marked as dirty; nevernull
requiredClassMode
- the class mode required for a context to be marked dirty in the current phase; nevernull
- 抛出:
Exception
- allows any exception to propagate- 从以下版本开始:
- 4.2
- 另请参阅:
dirtyContext(org.springframework.test.context.TestContext, org.springframework.test.annotation.DirtiesContext.HierarchyMode)