Class MethodArgumentsProvider
java.lang.Object
org.junit.jupiter.params.provider.AnnotationBasedArgumentsProvider<MethodSource>
org.junit.jupiter.params.provider.MethodArgumentsProvider
- All Implemented Interfaces:
Consumer<MethodSource>
,ArgumentsProvider
,AnnotationConsumer<MethodSource>
- Since:
- 5.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Method
findFactoryMethod
(Class<?> testClass, Method testMethod, String factoryMethodName) (package private) static Method
findFactoryMethodByFullyQualifiedName
(Class<?> testClass, Method testMethod, String fullyQualifiedMethodName) private static Method
findFactoryMethodBySimpleName
(Class<?> clazz, Method testMethod, String factoryMethodName) Find the factory method by searching for all methods in the givenclazz
with the desiredfactoryMethodName
which have return types that can be converted to aStream
, ignoring thetestMethod
itself as well as any@Test
,@TestTemplate
, or@TestFactory
methods with the same name.private static boolean
isTestMethod
(Method candidate) private static Class
<?> loadRequiredClass
(String className, ClassLoader classLoader) private static boolean
looksLikeAFullyQualifiedMethodName
(String factoryMethodName) provideArguments
(org.junit.jupiter.api.extension.ExtensionContext context, MethodSource methodSource) private static Arguments
toArguments
(Object item) private static Method
validateFactoryMethod
(Method factoryMethod, Object testInstance) Methods inherited from class org.junit.jupiter.params.provider.AnnotationBasedArgumentsProvider
accept, provideArguments
-
Field Details
-
isFactoryMethod
-
-
Constructor Details
-
MethodArgumentsProvider
MethodArgumentsProvider()
-
-
Method Details
-
provideArguments
protected Stream<? extends Arguments> provideArguments(org.junit.jupiter.api.extension.ExtensionContext context, MethodSource methodSource) Description copied from class:AnnotationBasedArgumentsProvider
Provide aStream
ofArguments
— based on metadata in the provided annotation — to be passed to a@ParameterizedTest
method.- Specified by:
provideArguments
in classAnnotationBasedArgumentsProvider<MethodSource>
- Parameters:
context
- the current extension context; nevernull
methodSource
- the annotation to process; nevernull
- Returns:
- a stream of arguments; never
null
-
findFactoryMethod
-
looksLikeAFullyQualifiedMethodName
-
findFactoryMethodByFullyQualifiedName
-
findFactoryMethodBySimpleName
private static Method findFactoryMethodBySimpleName(Class<?> clazz, Method testMethod, String factoryMethodName) Find the factory method by searching for all methods in the givenclazz
with the desiredfactoryMethodName
which have return types that can be converted to aStream
, ignoring thetestMethod
itself as well as any@Test
,@TestTemplate
, or@TestFactory
methods 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
-
loadRequiredClass
-
validateFactoryMethod
-
toArguments
-