public class DirtiesContextTestExecutionListener extends AbstractTestExecutionListener
TestExecutionListener which provides support for marking the
ApplicationContext associated with a test as dirty for
both test classes and test methods configured with the @DirtiesContext annotation.DirtiesContext| Constructor and Description |
|---|
DirtiesContextTestExecutionListener() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterTestClass(TestContext testContext)
If the test class of the supplied test context is
annotated with
@DirtiesContext, the
application context of the test context will
be marked as dirty,
and the
REINJECT_DEPENDENCIES_ATTRIBUTE in the test context will be set to
true. |
void |
afterTestMethod(TestContext testContext)
If the current test method of the supplied test
context is annotated with
@DirtiesContext,
or if the test class is annotated with @DirtiesContext and the class
mode is set to AFTER_EACH_TEST_METHOD, the application
context of the test context will be
marked as dirty and the
DependencyInjectionTestExecutionListener.REINJECT_DEPENDENCIES_ATTRIBUTE
in the test context will be set to true. |
protected void |
dirtyContext(TestContext testContext,
DirtiesContext.HierarchyMode hierarchyMode)
Marks the application context of the supplied
test context as
dirty
and sets
DependencyInjectionTestExecutionListener.REINJECT_DEPENDENCIES_ATTRIBUTE
in the test context to true. |
beforeTestClass, beforeTestMethod, prepareTestInstanceprotected void dirtyContext(TestContext testContext, DirtiesContext.HierarchyMode hierarchyMode)
DependencyInjectionTestExecutionListener.REINJECT_DEPENDENCIES_ATTRIBUTE
in the test context to true.testContext - the test context whose application context should
marked as dirtyhierarchyMode - the context cache clearing mode to be applied if the
context is part of a hierarchy; may be nullpublic void afterTestMethod(TestContext testContext) throws Exception
@DirtiesContext,
or if the test class is annotated with @DirtiesContext and the class
mode is set to AFTER_EACH_TEST_METHOD, the application
context of the test context will be
marked as dirty and the
DependencyInjectionTestExecutionListener.REINJECT_DEPENDENCIES_ATTRIBUTE
in the test context will be set to true.afterTestMethod in interface TestExecutionListenerafterTestMethod in class AbstractTestExecutionListenertestContext - the test context in which the test method was
executed; never nullException - allows any exception to propagatepublic void afterTestClass(TestContext testContext) throws Exception
@DirtiesContext, the
application context of the test context will
be marked as dirty,
and the
REINJECT_DEPENDENCIES_ATTRIBUTE in the test context will be set to
true.afterTestClass in interface TestExecutionListenerafterTestClass in class AbstractTestExecutionListenertestContext - the test context for the test; never nullException - allows any exception to propagate