Class DirtiesContextTestExecutionListener
java.lang.Object
org.springframework.test.context.support.AbstractTestExecutionListener
org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener
org.springframework.test.context.support.DirtiesContextTestExecutionListener
- All Implemented Interfaces:
Ordered,TestExecutionListener
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.
- Since:
- 2.5
- Author:
- Sam Brannen
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterTestClass(TestContext testContext) If the test class of the supplied test context is annotated with@DirtiesContextand the class mode is set toAFTER_CLASS, the application context of the test context will be marked as dirty, and theREINJECT_DEPENDENCIES_ATTRIBUTEin the test context will be set totrue.voidafterTestMethod(TestContext testContext) If the current test method of the supplied test context is annotated with@DirtiesContextand the method mode is set toAFTER_METHOD, or if the test class is annotated with@DirtiesContextand the class mode is set toAFTER_EACH_TEST_METHOD, the application context of the test context will be marked as dirty and theREINJECT_DEPENDENCIES_ATTRIBUTEin the test context will be set totrue.final intgetOrder()Returns3000.Methods inherited from class org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener
beforeOrAfterTestClass, beforeOrAfterTestMethod, dirtyContextMethods inherited from class org.springframework.test.context.support.AbstractTestExecutionListener
afterTestExecution, beforeTestClass, beforeTestExecution, beforeTestMethod, prepareTestInstance
-
Constructor Details
-
DirtiesContextTestExecutionListener
public DirtiesContextTestExecutionListener()
-
-
Method Details
-
getOrder
public final int getOrder()Returns3000.- Specified by:
getOrderin interfaceOrdered- Specified by:
getOrderin classAbstractDirtiesContextTestExecutionListener- Returns:
- the order value
- See Also:
-
afterTestMethod
If the current test method of the supplied test context is annotated with@DirtiesContextand the method mode is set toAFTER_METHOD, or if the test class is annotated with@DirtiesContextand the class mode is set toAFTER_EACH_TEST_METHOD, the application context of the test context will be marked as dirty and theREINJECT_DEPENDENCIES_ATTRIBUTEin the test context will be set totrue.- Specified by:
afterTestMethodin interfaceTestExecutionListener- Overrides:
afterTestMethodin classAbstractTestExecutionListener- Parameters:
testContext- the test context in which the test method was executed; nevernull- Throws:
Exception- allows any exception to propagate- See Also:
-
afterTestClass
If the test class of the supplied test context is annotated with@DirtiesContextand the class mode is set toAFTER_CLASS, the application context of the test context will be marked as dirty, and theREINJECT_DEPENDENCIES_ATTRIBUTEin the test context will be set totrue.- Specified by:
afterTestClassin interfaceTestExecutionListener- Overrides:
afterTestClassin classAbstractTestExecutionListener- Parameters:
testContext- the test context for the test; nevernull- Throws:
Exception- allows any exception to propagate
-