@API(value=Experimental) public interface ParameterResolver extends Extension
ParameterResolver
defines the API for Extensions
that wish to dynamically resolve parameters at runtime.
If a constructor for a test class or a
@Test
,
@BeforeEach
,
@AfterEach
,
@BeforeAll
, or
@AfterAll
method accepts a parameter,
the parameter must be resolved at runtime by a ParameterResolver
.
Implementations must provide a no-args constructor.
Modifier and Type | Method and Description |
---|---|
Object |
resolve(ParameterContext parameterContext,
ExtensionContext extensionContext)
|
boolean |
supports(ParameterContext parameterContext,
ExtensionContext extensionContext)
Determine if this resolver supports resolution of the
Parameter
in the supplied ParameterContext for the supplied
ExtensionContext . |
boolean supports(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException
Parameter
in the supplied ParameterContext
for the supplied
ExtensionContext
.
The Method
or Constructor
in which the parameter is declared can be retrieved via
ParameterContext.getDeclaringExecutable()
.
parameterContext
- the context for the parameter to be resolved; never
null
extensionContext
- the extension context for the Executable
about to be invoked; never null
true
if this resolver can resolve the parameterParameterResolutionException
resolve(org.junit.jupiter.api.extension.ParameterContext, org.junit.jupiter.api.extension.ExtensionContext)
,
ParameterContext
Object resolve(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException
Parameter
in the supplied ParameterContext
for the supplied ExtensionContext
.
This method is only called by the framework if supports(org.junit.jupiter.api.extension.ParameterContext, org.junit.jupiter.api.extension.ExtensionContext)
has
previously returned true
for the same ParameterContext
and ExtensionContext
.
The Method
or Constructor
in which the parameter is declared can be retrieved via
ParameterContext.getDeclaringExecutable()
.
parameterContext
- the context for the parameter to be resolved; never
null
extensionContext
- the extension context for the Executable
about to be invoked; never null
null
if the
parameter type is not a primitiveParameterResolutionException
supports(org.junit.jupiter.api.extension.ParameterContext, org.junit.jupiter.api.extension.ExtensionContext)
,
ParameterContext