Class MockitoTestExecutionListener
java.lang.Object
org.springframework.test.context.support.AbstractTestExecutionListener
org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener
- All Implemented Interfaces:
org.springframework.core.Ordered
,org.springframework.test.context.TestExecutionListener
public class MockitoTestExecutionListener
extends org.springframework.test.context.support.AbstractTestExecutionListener
TestExecutionListener
to enable @MockBean
and
@SpyBean
support. Also triggers
MockitoAnnotations.openMocks(Object)
when any Mockito annotations used,
primarily to allow @Captor
annotations.
To use the automatic reset support of @MockBean
and @SpyBean
, configure
ResetMocksTestExecutionListener
as well.
- Since:
- 1.4.2
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterTestMethod
(org.springframework.test.context.TestContext testContext) void
beforeTestMethod
(org.springframework.test.context.TestContext testContext) final int
getOrder()
void
prepareTestInstance
(org.springframework.test.context.TestContext testContext) Methods inherited from class org.springframework.test.context.support.AbstractTestExecutionListener
afterTestClass, afterTestExecution, beforeTestClass, beforeTestExecution
-
Constructor Details
-
MockitoTestExecutionListener
public MockitoTestExecutionListener()
-
-
Method Details
-
getOrder
public final int getOrder()- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
- Overrides:
getOrder
in classorg.springframework.test.context.support.AbstractTestExecutionListener
-
prepareTestInstance
public void prepareTestInstance(org.springframework.test.context.TestContext testContext) throws Exception - Specified by:
prepareTestInstance
in interfaceorg.springframework.test.context.TestExecutionListener
- Overrides:
prepareTestInstance
in classorg.springframework.test.context.support.AbstractTestExecutionListener
- Throws:
Exception
-
beforeTestMethod
public void beforeTestMethod(org.springframework.test.context.TestContext testContext) throws Exception - Specified by:
beforeTestMethod
in interfaceorg.springframework.test.context.TestExecutionListener
- Overrides:
beforeTestMethod
in classorg.springframework.test.context.support.AbstractTestExecutionListener
- Throws:
Exception
-
afterTestMethod
public void afterTestMethod(org.springframework.test.context.TestContext testContext) throws Exception - Specified by:
afterTestMethod
in interfaceorg.springframework.test.context.TestExecutionListener
- Overrides:
afterTestMethod
in classorg.springframework.test.context.support.AbstractTestExecutionListener
- Throws:
Exception
-