Class MethodArgumentsProvider

All Implemented Interfaces:
Consumer<MethodSource>, ArgumentsProvider, AnnotationConsumer<MethodSource>

class MethodArgumentsProvider extends AnnotationBasedArgumentsProvider<MethodSource>
Since:
5.0
  • Field Details

  • 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 a Stream of Arguments — based on metadata in the provided annotation — to be passed to a @ParameterizedTest method.
      Specified by:
      provideArguments in class AnnotationBasedArgumentsProvider<MethodSource>
      Parameters:
      context - the current extension context; never null
      methodSource - the annotation to process; never null
      Returns:
      a stream of arguments; never null
    • findFactoryMethod

      private static Method findFactoryMethod(Class<?> testClass, Method testMethod, String factoryMethodName)
    • looksLikeAFullyQualifiedMethodName

      private static boolean looksLikeAFullyQualifiedMethodName(String factoryMethodName)
    • findFactoryMethodByFullyQualifiedName

      static Method findFactoryMethodByFullyQualifiedName(Class<?> testClass, Method testMethod, String fullyQualifiedMethodName)
    • findFactoryMethodBySimpleName

      private static Method findFactoryMethodBySimpleName(Class<?> clazz, Method testMethod, String factoryMethodName)
      Find the factory method by searching for all methods in the given clazz with the desired factoryMethodName which have return types that can be converted to a Stream, ignoring the testMethod 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

      private static boolean isTestMethod(Method candidate)
    • loadRequiredClass

      private static Class<?> loadRequiredClass(String className, ClassLoader classLoader)
    • validateFactoryMethod

      private static Method validateFactoryMethod(Method factoryMethod, Object testInstance)
    • toArguments

      private static Arguments toArguments(Object item)