Package org.junit.jupiter.params
Class ParameterizedTestMethodContext
java.lang.Object
org.junit.jupiter.params.ParameterizedTestMethodContext
Encapsulates access to the parameters of a parameterized test method and
caches the converters and aggregators used to resolve them.
- Since:
- 5.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
(package private) static class
(package private) static interface
(package private) static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Parameter[]
private final ParameterizedTestMethodContext.Resolver[]
private final List
<ParameterizedTestMethodContext.ResolverType> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) int
Get the number of parameters of theMethod
represented by this context.getParameterName
(int parameterIndex) Get the name of theParameter
with the supplied index, if it is present and declared before the aggregators.getResolver
(org.junit.jupiter.api.extension.ParameterContext parameterContext) (package private) boolean
Determine if theMethod
represented by this context declares at least oneParameter
that is an aggregator.(package private) boolean
Determine if theMethod
represented by this context has a potentially valid signature (i.e., formal parameter declarations) with regard to aggregators.(package private) int
(package private) boolean
isAggregator
(int parameterIndex) Determine if theParameter
with the supplied index is an aggregator (i.e., of typeArgumentsAccessor
or annotated withAggregateWith
).private static boolean
isAggregator
(Parameter parameter) Determine if the suppliedParameter
is an aggregator (i.e., of typeArgumentsAccessor
or annotated withAggregateWith
).private static org.junit.jupiter.api.extension.ParameterResolutionException
parameterResolutionException
(String message, Exception cause, org.junit.jupiter.api.extension.ParameterContext parameterContext) (package private) Object
resolve
(org.junit.jupiter.api.extension.ParameterContext parameterContext, Object[] arguments, int invocationIndex) Resolve the parameter for the supplied context using the supplied arguments.
-
Field Details
-
parameters
-
resolvers
-
resolverTypes
-
-
Constructor Details
-
ParameterizedTestMethodContext
ParameterizedTestMethodContext(Method testMethod)
-
-
Method Details
-
isAggregator
Determine if the suppliedParameter
is an aggregator (i.e., of typeArgumentsAccessor
or annotated withAggregateWith
).- Returns:
true
if the parameter is an aggregator
-
hasPotentiallyValidSignature
boolean hasPotentiallyValidSignature()Determine if theMethod
represented by this context has a potentially valid signature (i.e., formal parameter declarations) with regard to aggregators.This method takes a best-effort approach at enforcing the following policy for parameterized test methods that accept aggregators as arguments.
- zero or more indexed arguments come first.
- zero or more aggregators come next.
- zero or more arguments supplied by other
ParameterResolver
implementations come last.
- Returns:
true
if the method has a potentially valid signature
-
getParameterCount
int getParameterCount()Get the number of parameters of theMethod
represented by this context. -
getParameterName
Get the name of theParameter
with the supplied index, if it is present and declared before the aggregators.- Returns:
- an
Optional
containing the name of the parameter
-
hasAggregator
boolean hasAggregator()Determine if theMethod
represented by this context declares at least oneParameter
that is an aggregator.- Returns:
true
if the method has an aggregator
-
isAggregator
boolean isAggregator(int parameterIndex) Determine if theParameter
with the supplied index is an aggregator (i.e., of typeArgumentsAccessor
or annotated withAggregateWith
).- Returns:
true
if the parameter is an aggregator
-
indexOfFirstAggregator
int indexOfFirstAggregator()- Returns:
- the index of the first aggregator, or
-1
if not found
-
resolve
Object resolve(org.junit.jupiter.api.extension.ParameterContext parameterContext, Object[] arguments, int invocationIndex) Resolve the parameter for the supplied context using the supplied arguments. -
getResolver
private ParameterizedTestMethodContext.Resolver getResolver(org.junit.jupiter.api.extension.ParameterContext parameterContext) -
parameterResolutionException
-