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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterTestClass(org.springframework.test.context.TestContext testContext) voidafterTestMethod(org.springframework.test.context.TestContext testContext) voidbeforeTestMethod(org.springframework.test.context.TestContext testContext) final intgetOrder()voidprepareTestInstance(org.springframework.test.context.TestContext testContext) 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()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered- Overrides:
getOrderin classorg.springframework.test.context.support.AbstractTestExecutionListener
-
prepareTestInstance
public void prepareTestInstance(org.springframework.test.context.TestContext testContext) throws Exception - Specified by:
prepareTestInstancein interfaceorg.springframework.test.context.TestExecutionListener- Overrides:
prepareTestInstancein classorg.springframework.test.context.support.AbstractTestExecutionListener- Throws:
Exception
-
beforeTestMethod
public void beforeTestMethod(org.springframework.test.context.TestContext testContext) throws Exception - Specified by:
beforeTestMethodin interfaceorg.springframework.test.context.TestExecutionListener- Overrides:
beforeTestMethodin classorg.springframework.test.context.support.AbstractTestExecutionListener- Throws:
Exception
-
afterTestMethod
public void afterTestMethod(org.springframework.test.context.TestContext testContext) throws Exception - Specified by:
afterTestMethodin interfaceorg.springframework.test.context.TestExecutionListener- Overrides:
afterTestMethodin classorg.springframework.test.context.support.AbstractTestExecutionListener- Throws:
Exception
-
afterTestClass
public void afterTestClass(org.springframework.test.context.TestContext testContext) throws Exception - Specified by:
afterTestClassin interfaceorg.springframework.test.context.TestExecutionListener- Overrides:
afterTestClassin classorg.springframework.test.context.support.AbstractTestExecutionListener- Throws:
Exception
-