@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 |
|---|---|
java.lang.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
nullextensionContext - the extension context for the Executable
about to be invoked; never nulltrue if this resolver can resolve the parameterParameterResolutionExceptionresolve(org.junit.jupiter.api.extension.ParameterContext, org.junit.jupiter.api.extension.ExtensionContext),
ParameterContextjava.lang.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
nullextensionContext - the extension context for the Executable
about to be invoked; never nullnull if the
parameter type is not a primitiveParameterResolutionExceptionsupports(org.junit.jupiter.api.extension.ParameterContext, org.junit.jupiter.api.extension.ExtensionContext),
ParameterContext