Package org.testng.internal
Class Parameters
java.lang.Object
org.testng.internal.Parameters
Methods that bind parameters declared in testng.xml to actual values used to invoke methods.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
Store the result of parameterTypes and optionalValues after filter out injected typesstatic class
A parameter passing helper class. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final List<Class<? extends Annotation>>
static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static boolean
areAllOptionalValuesNull
(String[] optionalValues) private static boolean
private static void
checkParameterTypes
(String methodName, Class<?>[] parameterTypes, String methodAnnotation, String[] parameterNames) static <T> T
convertType
(Class<T> type, String value, String paramName) static Object[]
createConfigurationParameters
(Method m, Map<String, String> params, Object[] parameterValues, ITestNGMethod currentTestMethod, IAnnotationFinder finder, XmlSuite xmlSuite, ITestContext ctx, ITestResult testResult) Creates the parameters needed for the specified@Configuration
Method
.static Object[]
createInstantiationParameters
(Constructor<?> ctor, String methodAnnotation, IAnnotationFinder finder, String[] parameterNames, Map<String, String> params, XmlSuite xmlSuite) Creates the parameters needed for constructing a test class instance.private static Object[]
createParameters
(ConstructorOrMethod m, Parameters.MethodParameters params, IAnnotationFinder finder, XmlSuite xmlSuite, String atName) private static Object[]
createParametersForConstructor
(Constructor<?> constructor, Class<?>[] parameterTypes, String[] optionalValues, String methodAnnotation, String[] parameterNames, Parameters.MethodParameters params, XmlSuite xmlSuite) private static Object[]
createParametersForMethod
(ConstructorOrMethod method, Class<?>[] parameterTypes, String[] optionalValues, String methodAnnotation, String[] parameterNames, Parameters.MethodParameters params, XmlSuite xmlSuite) createParams
(String name, String prefix, String methodAnnotation, Class<?>[] parameterTypes, String[] optionalValues, String[] parameterNames, Parameters.MethodParameters params, XmlSuite xmlSuite) private static String[]
extractOptionalValues
(IAnnotationFinder finder, ConstructorOrMethod consMethod) private static Parameter[]
extractParameters
(ConstructorOrMethod method) (package private) static Parameters.FilterOutInJectedTypesResult
filterOutInJectedTypesFromOptionalValues
(Class<?>[] parameterTypes, String[] optionalValues) Remove injected types from parameterTypes and optionalValuesprivate static IDataProviderMethod
findDataProvider
(Object instance, ITestClass clazz, IAnnotationFinder finder, String name, Class<?> dataProviderClass, ITestContext context) Find a method that has a @DataProvider(name=name)private static IDataProviderMethod
findDataProvider
(Object instance, ITestClass clazz, ConstructorOrMethod m, IAnnotationFinder finder, ITestContext context) private static IDataProvidable
findDataProviderInfo
(ITestClass clazz, ConstructorOrMethod m, IAnnotationFinder finder) Find the data provider info (data provider name and class) on either @Test(dataProvider),@Factory(dataProvider)
on a method or @Factory(dataProvider) on a constructor.private static String
static Object[]
getParametersFromIndex
(Iterator<Object[]> parametersValues, int index) static ParameterHolder
handleParameters
(ITestNGMethod testMethod, Map<String, String> allParameterNames, Object instance, Parameters.MethodParameters methodParams, XmlSuite xmlSuite, IAnnotationFinder annotationFinder, Object fedInstance, DataProviderHolder holder) If the method has parameters, fill them in.static ParameterHolder
handleParameters
(ITestNGMethod testMethod, Map<String, String> allParameterNames, Object instance, Parameters.MethodParameters methodParams, XmlSuite xmlSuite, IAnnotationFinder annotationFinder, Object fedInstance, DataProviderHolder holder, String annotationName) If the method has parameters, fill them in.static Object[]
injectParameters
(Object[] parameterValues, Method method, ITestContext context) Gets an array of parameter values returned by data provider or the ones that are injected based on parameter type.private static boolean
isDataProviderClassEmpty
(ITestAnnotation annotation) private static boolean
isDataProviderNameEmpty
(ITestAnnotation annotation) private static IDataProvidable
merge
(ITestAnnotation methodLevel, ITestAnnotation classLevel) private static String
prettyFormat
(List<Class<?>> classes) private static Class<? extends Annotation>
private static boolean
validParameters
(String methodAnnotation, Class<?>[] parameterTypes)
-
Field Details
-
NULL_VALUE
- See Also:
-
annotationList
-
mapping
-
INJECTED_TYPES
-
-
Constructor Details
-
Parameters
public Parameters()
-
-
Method Details
-
createInstantiationParameters
public static Object[] createInstantiationParameters(Constructor<?> ctor, String methodAnnotation, IAnnotationFinder finder, String[] parameterNames, Map<String, String> params, XmlSuite xmlSuite) Creates the parameters needed for constructing a test class instance. -
createConfigurationParameters
public static Object[] createConfigurationParameters(Method m, Map<String, String> params, Object[] parameterValues, @Nullable ITestNGMethod currentTestMethod, IAnnotationFinder finder, XmlSuite xmlSuite, ITestContext ctx, ITestResult testResult) Creates the parameters needed for the specified@Configuration
Method
.- Parameters:
m
- the configuraton methodcurrentTestMethod
- the current @Test method ornull
if no @Test is available (this is not only in case the configuration method is a @Before/@AfterMethodfinder
- the annotation finder
-
retrieveConfigAnnotation
-
createParametersForConstructor
private static Object[] createParametersForConstructor(Constructor<?> constructor, Class<?>[] parameterTypes, String[] optionalValues, String methodAnnotation, String[] parameterNames, Parameters.MethodParameters params, XmlSuite xmlSuite) -
createParams
-
filterOutInJectedTypesFromOptionalValues
static Parameters.FilterOutInJectedTypesResult filterOutInJectedTypesFromOptionalValues(Class<?>[] parameterTypes, String[] optionalValues) Remove injected types from parameterTypes and optionalValues- Parameters:
parameterTypes
- - The parameter types to be usedoptionalValues
- - The optional values to be considered.- Returns:
- FilterOutInJectedTypesResult
-
areAllOptionalValuesNull
-
createParametersForMethod
private static Object[] createParametersForMethod(ConstructorOrMethod method, Class<?>[] parameterTypes, String[] optionalValues, String methodAnnotation, String[] parameterNames, Parameters.MethodParameters params, XmlSuite xmlSuite) - Returns:
- An array of parameters suitable to invoke this method, possibly picked from the property file
-
extractParameters
-
canInject
-
checkParameterTypes
-
validParameters
-
prettyFormat
-
convertType
-
findDataProvider
private static IDataProviderMethod findDataProvider(Object instance, ITestClass clazz, ConstructorOrMethod m, IAnnotationFinder finder, ITestContext context) -
findDataProviderInfo
private static IDataProvidable findDataProviderInfo(ITestClass clazz, ConstructorOrMethod m, IAnnotationFinder finder) Find the data provider info (data provider name and class) on either @Test(dataProvider),@Factory(dataProvider)
on a method or @Factory(dataProvider) on a constructor. -
merge
-
isDataProviderClassEmpty
-
isDataProviderNameEmpty
-
findDataProvider
private static IDataProviderMethod findDataProvider(Object instance, ITestClass clazz, IAnnotationFinder finder, String name, Class<?> dataProviderClass, ITestContext context) Find a method that has a @DataProvider(name=name) -
getDataProviderName
-
extractOptionalValues
private static String[] extractOptionalValues(IAnnotationFinder finder, ConstructorOrMethod consMethod) -
createParameters
private static Object[] createParameters(ConstructorOrMethod m, Parameters.MethodParameters params, IAnnotationFinder finder, XmlSuite xmlSuite, String atName) -
handleParameters
public static ParameterHolder handleParameters(ITestNGMethod testMethod, Map<String, String> allParameterNames, Object instance, Parameters.MethodParameters methodParams, XmlSuite xmlSuite, IAnnotationFinder annotationFinder, Object fedInstance, DataProviderHolder holder) If the method has parameters, fill them in. Either by using a @DataProvider if any was provided, or by looking up<parameters>
in testng.xml- Returns:
- An Iterator over the values for each parameter of this method.
-
handleParameters
public static ParameterHolder handleParameters(ITestNGMethod testMethod, Map<String, String> allParameterNames, Object instance, Parameters.MethodParameters methodParams, XmlSuite xmlSuite, IAnnotationFinder annotationFinder, Object fedInstance, DataProviderHolder holder, String annotationName) If the method has parameters, fill them in. Either by using a @DataProvider if any was provided, or by looking up<parameters>
in testng.xml- Returns:
- An Iterator over the values for each parameter of this method.
-
injectParameters
public static Object[] injectParameters(Object[] parameterValues, Method method, ITestContext context) throws TestNGException Gets an array of parameter values returned by data provider or the ones that are injected based on parameter type. The method also checks forNoInjection
annotation- Parameters:
parameterValues
- parameter values from a data providermethod
- method to be invokedcontext
- test context- Throws:
TestNGException
-
getParametersFromIndex
-