public class DirtiesContextTestExecutionListener extends AbstractDirtiesContextTestExecutionListener
TestExecutionListener which provides support for marking the
ApplicationContext 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 to
AFTER_EACH_TEST_METHOD or
AFTER_CLASS. For support for BEFORE
modes, see DirtiesContextBeforeModesTestExecutionListener.
When merging
TestExecutionListeners with the defaults, this listener will
automatically be ordered after the DependencyInjectionTestExecutionListener;
otherwise, this listener must be manually configured to execute after the
DependencyInjectionTestExecutionListener.
DirtiesContext,
DirtiesContextBeforeModesTestExecutionListener| 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 and the class mode is set to AFTER_CLASS, 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 and the method mode is set to AFTER_METHOD, 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
REINJECT_DEPENDENCIES_ATTRIBUTE in the test context will be set to true. |
int |
getOrder()
Returns
3000. |
beforeOrAfterTestClass, beforeOrAfterTestMethod, dirtyContextbeforeTestClass, beforeTestMethod, prepareTestInstancepublic final int getOrder()
3000.getOrder in interface org.springframework.core.OrderedgetOrder in class AbstractDirtiesContextTestExecutionListenerpublic void afterTestMethod(TestContext testContext) throws Exception
@DirtiesContext and the method mode is set to AFTER_METHOD, 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
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 and the class mode is set to AFTER_CLASS, 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