Class SmartDirtiesContextTestExecutionListener
java.lang.Object
org.springframework.test.context.support.AbstractTestExecutionListener
com.github.seregamorph.testsmartcontext.SmartDirtiesContextTestExecutionListener
- All Implemented Interfaces:
org.springframework.core.Ordered,org.springframework.test.context.TestExecutionListener
public class SmartDirtiesContextTestExecutionListener
extends org.springframework.test.context.support.AbstractTestExecutionListener
Listener that works in more tricky way than spring
DirtiesContextTestExecutionListener. Based on known list (ordered)
of tests to execute (reordered via SmartDirtiesClassOrderer
for Jupiter classes, SmartDirtiesSuiteListener for TestNG
classes or SmartDirtiesPostDiscoveryFilter for JUnit 4 classes), the last test in each group that shares the
same configuration (=share the same spring context) will automatically close the ApplicationContext on after-class,
which will release resources as well (like Docker containers defined as spring beans). See detailed explanation README.- Author:
- Sergey Chernov
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterTestClass(org.springframework.test.context.TestContext testContext) voidbeforeTestClass(org.springframework.test.context.TestContext testContext) intgetOrder()Methods inherited from class org.springframework.test.context.support.AbstractTestExecutionListener
afterTestExecution, afterTestMethod, beforeTestExecution, beforeTestMethod, prepareTestInstance
-
Constructor Details
-
SmartDirtiesContextTestExecutionListener
public SmartDirtiesContextTestExecutionListener()
-
-
Method Details
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered- Overrides:
getOrderin classorg.springframework.test.context.support.AbstractTestExecutionListener
-
beforeTestClass
public void beforeTestClass(org.springframework.test.context.TestContext testContext) - Specified by:
beforeTestClassin interfaceorg.springframework.test.context.TestExecutionListener- Overrides:
beforeTestClassin classorg.springframework.test.context.support.AbstractTestExecutionListener
-
afterTestClass
public void afterTestClass(org.springframework.test.context.TestContext testContext) - Specified by:
afterTestClassin interfaceorg.springframework.test.context.TestExecutionListener- Overrides:
afterTestClassin classorg.springframework.test.context.support.AbstractTestExecutionListener
-