Class MethodArgumentsProvider
- java.lang.Object
-
- org.junit.jupiter.params.provider.AnnotationBasedArgumentsProvider<MethodSource>
-
- org.junit.jupiter.params.provider.MethodArgumentsProvider
-
- All Implemented Interfaces:
java.util.function.Consumer<MethodSource>,ArgumentsProvider,AnnotationConsumer<MethodSource>
class MethodArgumentsProvider extends AnnotationBasedArgumentsProvider<MethodSource>
- Since:
- 5.0
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.function.Predicate<java.lang.reflect.Method>isFactoryMethod
-
Constructor Summary
Constructors Constructor Description MethodArgumentsProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.reflect.MethodfindFactoryMethod(java.lang.Class<?> testClass, java.lang.reflect.Method testMethod, java.lang.String factoryMethodName)(package private) static java.lang.reflect.MethodfindFactoryMethodByFullyQualifiedName(java.lang.Class<?> testClass, java.lang.reflect.Method testMethod, java.lang.String fullyQualifiedMethodName)private static java.lang.reflect.MethodfindFactoryMethodBySimpleName(java.lang.Class<?> clazz, java.lang.reflect.Method testMethod, java.lang.String factoryMethodName)Find the factory method by searching for all methods in the givenclazzwith the desiredfactoryMethodNamewhich have return types that can be converted to aStream, ignoring thetestMethoditself as well as any@Test,@TestTemplate, or@TestFactorymethods with the same name.private static booleanisTestMethod(java.lang.reflect.Method candidate)private static java.lang.Class<?>loadRequiredClass(java.lang.String className, java.lang.ClassLoader classLoader)private static booleanlooksLikeAFullyQualifiedMethodName(java.lang.String factoryMethodName)protected java.util.stream.Stream<? extends Arguments>provideArguments(org.junit.jupiter.api.extension.ExtensionContext context, MethodSource methodSource)Provide aStreamofArguments— based on metadata in the provided annotation — to be passed to a@ParameterizedTestmethod.private static ArgumentstoArguments(java.lang.Object item)private static java.lang.reflect.MethodvalidateFactoryMethod(java.lang.reflect.Method factoryMethod, java.lang.Object testInstance)-
Methods inherited from class org.junit.jupiter.params.provider.AnnotationBasedArgumentsProvider
accept, provideArguments
-
-
-
-
Method Detail
-
provideArguments
protected java.util.stream.Stream<? extends Arguments> provideArguments(org.junit.jupiter.api.extension.ExtensionContext context, MethodSource methodSource)
Description copied from class:AnnotationBasedArgumentsProviderProvide aStreamofArguments— based on metadata in the provided annotation — to be passed to a@ParameterizedTestmethod.- Specified by:
provideArgumentsin classAnnotationBasedArgumentsProvider<MethodSource>- Parameters:
context- the current extension context; nevernullmethodSource- the annotation to process; nevernull- Returns:
- a stream of arguments; never
null
-
findFactoryMethod
private static java.lang.reflect.Method findFactoryMethod(java.lang.Class<?> testClass, java.lang.reflect.Method testMethod, java.lang.String factoryMethodName)
-
looksLikeAFullyQualifiedMethodName
private static boolean looksLikeAFullyQualifiedMethodName(java.lang.String factoryMethodName)
-
findFactoryMethodByFullyQualifiedName
static java.lang.reflect.Method findFactoryMethodByFullyQualifiedName(java.lang.Class<?> testClass, java.lang.reflect.Method testMethod, java.lang.String fullyQualifiedMethodName)
-
findFactoryMethodBySimpleName
private static java.lang.reflect.Method findFactoryMethodBySimpleName(java.lang.Class<?> clazz, java.lang.reflect.Method testMethod, java.lang.String factoryMethodName)Find the factory method by searching for all methods in the givenclazzwith the desiredfactoryMethodNamewhich have return types that can be converted to aStream, ignoring thetestMethoditself as well as any@Test,@TestTemplate, or@TestFactorymethods with the same name.- Returns:
- the single factory method matching the search criteria
- Throws:
org.junit.platform.commons.PreconditionViolationException- if the factory method was not found or multiple competing factory methods with the same name were found
-
isTestMethod
private static boolean isTestMethod(java.lang.reflect.Method candidate)
-
loadRequiredClass
private static java.lang.Class<?> loadRequiredClass(java.lang.String className, java.lang.ClassLoader classLoader)
-
validateFactoryMethod
private static java.lang.reflect.Method validateFactoryMethod(java.lang.reflect.Method factoryMethod, java.lang.Object testInstance)
-
toArguments
private static Arguments toArguments(java.lang.Object item)
-
-