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.util.Optional<java.lang.reflect.Method> testMethod, java.lang.String factoryMethodName)(package private) static java.lang.reflect.MethodfindFactoryMethodByFullyQualifiedName(java.lang.Class<?> testClass, java.util.Optional<java.lang.reflect.Method> testMethod, java.lang.String fullyQualifiedMethodName)private static java.lang.reflect.MethodfindFactoryMethodBySimpleName(java.lang.Class<?> clazz, java.util.Optional<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 booleanlooksLikeAFullyQualifiedMethodName(java.lang.String factoryMethodName)protected java.util.stream.Stream<? extends Arguments>provideArguments(ParameterDeclarations parameters, org.junit.jupiter.api.extension.ExtensionContext context, MethodSource methodSource)The returnedStreamwill beproperly closedby the default implementation ofAnnotationBasedArgumentsProvider.provideArguments(ParameterDeclarations, ExtensionContext), making it safe to use a resource such asFiles.lines().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, provideArguments
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.junit.jupiter.params.provider.ArgumentsProvider
provideArguments
-
-
-
-
Method Detail
-
provideArguments
protected java.util.stream.Stream<? extends Arguments> provideArguments(ParameterDeclarations parameters, org.junit.jupiter.api.extension.ExtensionContext context, MethodSource methodSource)
Description copied from class:AnnotationBasedArgumentsProviderThe returnedStreamwill beproperly closedby the default implementation ofAnnotationBasedArgumentsProvider.provideArguments(ParameterDeclarations, ExtensionContext), making it safe to use a resource such asFiles.lines().- Overrides:
provideArgumentsin classAnnotationBasedArgumentsProvider<MethodSource>
-
findFactoryMethod
private static java.lang.reflect.Method findFactoryMethod(java.lang.Class<?> testClass, java.util.Optional<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.util.Optional<java.lang.reflect.Method> testMethod, java.lang.String fullyQualifiedMethodName)
-
findFactoryMethodBySimpleName
private static java.lang.reflect.Method findFactoryMethodBySimpleName(java.lang.Class<?> clazz, java.util.Optional<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)
-
validateFactoryMethod
private static java.lang.reflect.Method validateFactoryMethod(java.lang.reflect.Method factoryMethod, java.lang.Object testInstance)
-
-