Class MockitoExtension
- java.lang.Object
-
- org.curioswitch.common.testing.mocking.MockitoExtension
-
- All Implemented Interfaces:
org.junit.jupiter.api.extension.BeforeEachCallback
,org.junit.jupiter.api.extension.Extension
,org.junit.jupiter.api.extension.ParameterResolver
,org.junit.jupiter.api.extension.TestInstancePostProcessor
@AutoService(org.junit.jupiter.api.extension.Extension.class) public class MockitoExtension extends java.lang.Object implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.TestInstancePostProcessor, org.junit.jupiter.api.extension.ParameterResolver
TODO(choko): Remove once mockito adds official junit5 support.MockitoExtension
showcases theTestInstancePostProcessor
andParameterResolver
extension APIs of JUnit 5 by providing dependency injection support at the field level and at the method parameter level via Mockito 2.x's@Mock
annotation.- Since:
- 5.0
-
-
Constructor Summary
Constructors Constructor Description MockitoExtension()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
void
postProcessTestInstance(java.lang.Object testInstance, org.junit.jupiter.api.extension.ExtensionContext context)
java.lang.Object
resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
boolean
supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
-
-
-
Method Detail
-
postProcessTestInstance
public void postProcessTestInstance(java.lang.Object testInstance, org.junit.jupiter.api.extension.ExtensionContext context)
- Specified by:
postProcessTestInstance
in interfaceorg.junit.jupiter.api.extension.TestInstancePostProcessor
-
supportsParameter
public boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
- Specified by:
supportsParameter
in interfaceorg.junit.jupiter.api.extension.ParameterResolver
-
resolveParameter
public java.lang.Object resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
- Specified by:
resolveParameter
in interfaceorg.junit.jupiter.api.extension.ParameterResolver
-
beforeEach
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) throws java.lang.Exception
- Specified by:
beforeEach
in interfaceorg.junit.jupiter.api.extension.BeforeEachCallback
- Throws:
java.lang.Exception
-
-