Parameter Resolver
Let's learn how to perform parameter resolution in JUnit 5.
Parameter resolution
Parameter resolution is accomplished by implementations of the extension interface ParameterResolver
. It has two methods to implement.
- The first method,
boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException
, checks if this resolver supports the resolution of a parameter. - The second method,
Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException
, resolves the parameter and returns its value.
The type of the first parameter of these two methods is ParameterContext
. It contains information about the parameter to resolve.
Get hands-on with 1400+ tech skills courses.