Class MockitoTestExecutionListener
java.lang.Object
org.springframework.test.context.support.AbstractTestExecutionListener
org.springframework.test.context.bean.override.mockito.MockitoTestExecutionListener
- All Implemented Interfaces:
Ordered
,TestExecutionListener
TestExecutionListener
that enables @MockitoBean
and
@MockitoSpyBean
support. Also triggers
MockitoAnnotations.openMocks(Object)
when any Mockito annotations are
used, primarily to support @Captor
annotations.
The automatic reset support for @MockBean
and @SpyBean
is
handled by the MockitoResetTestExecutionListener
.
- Since:
- 6.2
- Author:
- Simon Baslé, Phillip Webb, Andy Wilkinson, Moritz Halbritter
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterTestClass
(TestContext testContext) The default implementation is empty.void
afterTestMethod
(TestContext testContext) The default implementation is empty.void
beforeTestMethod
(TestContext testContext) The default implementation is empty.final int
getOrder()
Executes beforeDependencyInjectionTestExecutionListener
.void
prepareTestInstance
(TestContext testContext) The default implementation is empty.Methods inherited from class org.springframework.test.context.support.AbstractTestExecutionListener
afterTestExecution, beforeTestClass, beforeTestExecution
-
Constructor Details
-
MockitoTestExecutionListener
public MockitoTestExecutionListener()
-
-
Method Details
-
getOrder
public final int getOrder()Executes beforeDependencyInjectionTestExecutionListener
.- Specified by:
getOrder
in interfaceOrdered
- Overrides:
getOrder
in classAbstractTestExecutionListener
- Returns:
- the order value
- See Also:
-
prepareTestInstance
Description copied from class:AbstractTestExecutionListener
The default implementation is empty. Can be overridden by subclasses as necessary.- Specified by:
prepareTestInstance
in interfaceTestExecutionListener
- Overrides:
prepareTestInstance
in classAbstractTestExecutionListener
- Parameters:
testContext
- the test context for the test; nevernull
- Throws:
Exception
- allows any exception to propagate
-
beforeTestMethod
Description copied from class:AbstractTestExecutionListener
The default implementation is empty. Can be overridden by subclasses as necessary.- Specified by:
beforeTestMethod
in interfaceTestExecutionListener
- Overrides:
beforeTestMethod
in classAbstractTestExecutionListener
- Parameters:
testContext
- the test context in which the test method will be executed; nevernull
- Throws:
Exception
- allows any exception to propagate- See Also:
-
afterTestMethod
Description copied from class:AbstractTestExecutionListener
The default implementation is empty. Can be overridden by subclasses as necessary.- Specified by:
afterTestMethod
in interfaceTestExecutionListener
- Overrides:
afterTestMethod
in classAbstractTestExecutionListener
- Parameters:
testContext
- the test context in which the test method was executed; nevernull
- Throws:
Exception
- allows any exception to propagate- See Also:
-
afterTestClass
Description copied from class:AbstractTestExecutionListener
The default implementation is empty. Can be overridden by subclasses as necessary.- Specified by:
afterTestClass
in interfaceTestExecutionListener
- Overrides:
afterTestClass
in classAbstractTestExecutionListener
- Parameters:
testContext
- the test context for the test; nevernull
- Throws:
Exception
- allows any exception to propagate
-