public class ApplicationEventsTestExecutionListener extends AbstractTestExecutionListener
TestExecutionListener
which provides support for ApplicationEvents
.
This listener manages the registration of ApplicationEvents
for the
current thread at various points within the test execution lifecycle and makes
the current instance of ApplicationEvents
available to tests via an
@Autowired
field in the test class.
If the test class is not annotated or meta-annotated with
@RecordApplicationEvents
, this listener
effectively does nothing.
ApplicationEvents
,
ApplicationEventsHolder
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
ApplicationEventsTestExecutionListener() |
Modifier and Type | Method and Description |
---|---|
void |
afterTestMethod(TestContext testContext)
The default implementation is empty.
|
void |
beforeTestMethod(TestContext testContext)
The default implementation is empty.
|
int |
getOrder()
Returns
1800 . |
void |
prepareTestInstance(TestContext testContext)
The default implementation is empty.
|
afterTestClass, afterTestExecution, beforeTestClass, beforeTestExecution
public ApplicationEventsTestExecutionListener()
public final int getOrder()
1800
.getOrder
in interface Ordered
getOrder
in class AbstractTestExecutionListener
Ordered.HIGHEST_PRECEDENCE
,
Ordered.LOWEST_PRECEDENCE
public void prepareTestInstance(TestContext testContext) throws Exception
AbstractTestExecutionListener
prepareTestInstance
in interface TestExecutionListener
prepareTestInstance
in class AbstractTestExecutionListener
testContext
- the test context for the test; never null
Exception
- allows any exception to propagatepublic void beforeTestMethod(TestContext testContext) throws Exception
AbstractTestExecutionListener
beforeTestMethod
in interface TestExecutionListener
beforeTestMethod
in class AbstractTestExecutionListener
testContext
- the test context in which the test method will be
executed; never null
Exception
- allows any exception to propagateTestExecutionListener.afterTestMethod(org.springframework.test.context.TestContext)
,
TestExecutionListener.beforeTestExecution(org.springframework.test.context.TestContext)
,
TestExecutionListener.afterTestExecution(org.springframework.test.context.TestContext)
public void afterTestMethod(TestContext testContext) throws Exception
AbstractTestExecutionListener
afterTestMethod
in interface TestExecutionListener
afterTestMethod
in class AbstractTestExecutionListener
testContext
- the test context in which the test method was
executed; never null
Exception
- allows any exception to propagateTestExecutionListener.beforeTestMethod(org.springframework.test.context.TestContext)
,
TestExecutionListener.beforeTestExecution(org.springframework.test.context.TestContext)
,
TestExecutionListener.afterTestExecution(org.springframework.test.context.TestContext)