Top Description Inners Fields Constructors Methods
org.testng.internal

public Class Parameters

extends Object
Class Inheritance
Imports
java.lang.annotation.Annotation, java.lang.reflect.Constructor, .Method, .Modifier, .Parameter, java.util.*, org.testng.DataProviderHolder, .IDataProviderInterceptor, .IDataProviderListener, .IDataProviderMethod, .IRetryDataProvider, .ITestClass, .ITestContext, .ITestNGMethod, .ITestObjectFactory, .ITestResult, .TestNGException, org.testng.annotations.*, org.testng.collections.Lists, .Maps, org.testng.internal.annotations.AnnotationHelper, .IAnnotationFinder, .IDataProvidable, org.testng.internal.collections.ArrayIterator, org.testng.internal.invokers.MethodInvocationHelper, .ParameterHolder, .ParameterHolder.ParameterOrigin, org.testng.internal.objects.Dispenser, .IObjectDispenser, org.testng.internal.objects.pojo.BasicAttributes, .CreationAttributes, org.testng.internal.reflect.DataProviderMethodMatcher, .InjectableParameter, .MethodMatcher, .MethodMatcherContext, .ReflectionRecipes, org.testng.util.Strings, org.testng.xml.XmlSuite, .XmlTest

Methods that bind parameters declared in testng.xml to actual values used to invoke methods.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
Parameters.FilterOutInjectedTypesResult

Store the result of parameterTypes and optionalValues after filter out injected types

public static class
Parameters.MethodParameters

A parameter passing helper class.

Field Summary

Modifier and TypeField and Description
private static final List<Class<? extends Annotation>>
private static final List<Class<?>>
private static final Map<String, List<Class<?>>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static boolean
areAllOptionalValuesNull(String[] optionalValues)

private static boolean
canInject(String annotation)

private static void
checkParameterTypes(String methodName, Class<?>[] parameterTypes, String methodAnnotation, String[] parameterNames)

public static Object[]
createConfigurationParameters(Method
the configuraton method
m
,
Map<String, String> params, Object[] parameterValues, ITestNGMethod
the current @Test method or null if no @Test is available (this is not only in case the configuration method is a @Before/@AfterMethod
currentTestMethod
,
IAnnotationFinder
the annotation finder
finder
,
XmlSuite xmlSuite, ITestContext ctx, ITestResult testResult)

Creates the parameters needed for the specified @Configuration Method .

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.

private static Object[]
private static Object[]
createParametersForConstructor(Constructor<?> constructor, Class<?>[] parameterTypes, String[] optionalValues, String methodAnnotation, String[] parameterNames, Parameters.MethodParameters params, XmlSuite xmlSuite)

private static Object[]

Returns:

An array of parameters suitable to invoke this method, possibly picked from the property file
createParametersForMethod
(ConstructorOrMethod method, Class<?>[] parameterTypes, String[] optionalValues, String methodAnnotation, String[] parameterNames, Parameters.MethodParameters params, XmlSuite xmlSuite)

private static List<Object>
createParams(String name, String prefix, String methodAnnotation, Class<?>[] parameterTypes, String[] optionalValues, String[] parameterNames, Parameters.MethodParameters params, XmlSuite xmlSuite)

private static String[]
private static Parameter[]
pack-priv static Parameters.FilterOutInjectedTypesResult

Returns:

FilterOutInjectedTypesResult
filterOutInjectedTypesFromOptionalValues
(Class<?>[]
- The parameter types to be used
parameterTypes
,
String[]
- The optional values to be considered.
optionalValues
)

Remove injected types from parameterTypes and optionalValues

private static IDataProviderMethod
private static IDataProviderMethod
findDataProvider(ITestObjectFactory objectFactory, Object instance, ITestClass clazz, IAnnotationFinder finder, String name, Class<?> dataProviderClass, boolean isDynamicDataProvider, ITestContext context)

Find a method that has a @DataProvider(name=name)

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
public static ParameterHolder

Returns:

An Iterator over the values for each parameter of this method.
handleParameters
(ITestObjectFactory objectFactory, 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

public static ParameterHolder

Returns:

An Iterator over the values for each parameter of this method.
handleParameters
(ITestObjectFactory objectFactory, 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

public static Object[]
injectParameters(Object[]
parameter values from a data provider
parameterValues
,
Method
method to be invoked
method
,
ITestContext
test context
context
)

Gets an array of parameter values returned by data provider or the ones that are injected based on parameter type.

private static boolean
private static boolean
private static boolean
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)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

annotationListback to summary
private static final List<Class<? extends Annotation>> annotationList
INJECTED_TYPESback to summary
private static final List<Class<?>> INJECTED_TYPES
mappingback to summary
private static final Map<String, List<Class<?>>> mapping

Constructor Detail

Parametersback to summary
public Parameters()

Method Detail

areAllOptionalValuesNullback to summary
private static boolean areAllOptionalValuesNull(String[] optionalValues)
canInjectback to summary
private static boolean canInject(String annotation)
checkParameterTypesback to summary
private static void checkParameterTypes(String methodName, Class<?>[] parameterTypes, String methodAnnotation, String[] parameterNames)
createConfigurationParametersback to summary
public 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 .

Parameters
m:Method

the configuraton method

currentTestMethod:ITestNGMethod

the current @Test method or null if no @Test is available (this is not only in case the configuration method is a @Before/@AfterMethod

finder:IAnnotationFinder

the annotation finder

createInstantiationParametersback to summary
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.

createParametersback to summary
private static Object[] createParameters(ConstructorOrMethod m, Parameters.MethodParameters params, IAnnotationFinder finder, XmlSuite xmlSuite, String atName)
createParametersForConstructorback to summary
private static Object[] createParametersForConstructor(Constructor<?> constructor, Class<?>[] parameterTypes, String[] optionalValues, String methodAnnotation, String[] parameterNames, Parameters.MethodParameters params, XmlSuite xmlSuite)
createParametersForMethodback to summary
private static Object[] createParametersForMethod(ConstructorOrMethod method, Class<?>[] parameterTypes, String[] optionalValues, String methodAnnotation, String[] parameterNames, Parameters.MethodParameters params, XmlSuite xmlSuite)
Returns:Object[]

An array of parameters suitable to invoke this method, possibly picked from the property file

createParamsback to summary
private static List<Object> createParams(String name, String prefix, String methodAnnotation, Class<?>[] parameterTypes, String[] optionalValues, String[] parameterNames, Parameters.MethodParameters params, XmlSuite xmlSuite)
extractOptionalValuesback to summary
private static String[] extractOptionalValues(IAnnotationFinder finder, ConstructorOrMethod consMethod)
extractParametersback to summary
private static Parameter[] extractParameters(ConstructorOrMethod method)
filterOutInjectedTypesFromOptionalValuesback to summary
pack-priv static Parameters.FilterOutInjectedTypesResult filterOutInjectedTypesFromOptionalValues(Class<?>[] parameterTypes, String[] optionalValues)

Remove injected types from parameterTypes and optionalValues

Parameters
parameterTypes:Class<?>[]

- The parameter types to be used

optionalValues:String[]

- The optional values to be considered.

Returns:Parameters.FilterOutInjectedTypesResult

FilterOutInjectedTypesResult

findDataProviderback to summary
private static IDataProviderMethod findDataProvider(ITestObjectFactory objectFactory, Object instance, ITestClass clazz, ConstructorOrMethod m, IAnnotationFinder finder, ITestContext context)
findDataProviderback to summary
private static IDataProviderMethod findDataProvider(ITestObjectFactory objectFactory, Object instance, ITestClass clazz, IAnnotationFinder finder, String name, Class<?> dataProviderClass, boolean isDynamicDataProvider, ITestContext context)

Find a method that has a @DataProvider(name=name)

findDataProviderInfoback to summary
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.

getDataProviderNameback to summary
private static String getDataProviderName(IDataProviderAnnotation dp, Method m)
handleParametersback to summary
public static ParameterHolder handleParameters(ITestObjectFactory objectFactory, 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:ParameterHolder

An Iterator over the values for each parameter of this method.

handleParametersback to summary
public static ParameterHolder handleParameters(ITestObjectFactory objectFactory, 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:ParameterHolder

An Iterator over the values for each parameter of this method.

injectParametersback to summary
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 for NoInjection annotation

Parameters
parameterValues:Object[]

parameter values from a data provider

method:Method

method to be invoked

context:ITestContext

test context

isDataProviderClassEmptyback to summary
private static boolean isDataProviderClassEmpty(ITestAnnotation annotation)
isDataProviderNameEmptyback to summary
private static boolean isDataProviderNameEmpty(ITestAnnotation annotation)
isDynamicDataProviderClassEmptyback to summary
private static boolean isDynamicDataProviderClassEmpty(ITestAnnotation annotation)
mergeback to summary
private static IDataProvidable merge(ITestAnnotation methodLevel, ITestAnnotation classLevel)
prettyFormatback to summary
private static String prettyFormat(List<Class<?>> classes)
retrieveConfigAnnotationback to summary
private static Class<? extends Annotation> retrieveConfigAnnotation(Method m)
validParametersback to summary
private static boolean validParameters(String methodAnnotation, Class<?>[] parameterTypes)
org.testng.internal back to summary

pack-priv final Class Parameters.FilterOutInjectedTypesResult

extends Object
Class Inheritance

Store the result of parameterTypes and optionalValues after filter out injected types

Field Summary

Modifier and TypeField and Description
private final String[]
private final Class<?>[]

Constructor Summary

AccessConstructor and Description
private
FilterOutInjectedTypesResult(Class<?>[] parameterTypes, String[] optionalValues)

Method Summary

Modifier and TypeMethod and Description
pack-priv String[]
pack-priv Class<?>[]
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

optionalValuesback to summary
private final String[] optionalValues
parameterTypesback to summary
private final Class<?>[] parameterTypes

Constructor Detail

FilterOutInjectedTypesResultback to summary
private FilterOutInjectedTypesResult(Class<?>[] parameterTypes, String[] optionalValues)

Method Detail

getOptionalValuesback to summary
pack-priv String[] getOptionalValues()
getParameterTypesback to summary
pack-priv Class<?>[] getParameterTypes()
org.testng.internal back to summary

public Class Parameters.MethodParameters

extends Object
Class Inheritance

A parameter passing helper class.

Field Summary

Modifier and TypeField and Description
private final ITestContext
private final Method
private final Object[]
private final ITestResult
private final Map<String, String>

Constructor Summary

AccessConstructor and Description
public
MethodParameters(Map<String, String> params, Map<String, String> methodParams)

public
MethodParameters(Map<String, String>
parameters found in the suite and test tags
params
,
Map<String, String>
parameters found in the include tag
methodParams
,
Object[]
parameter values to be used.
pv
,
Method
the Method object.
m
,
ITestContext
The ITestContext object representing the current test
ctx
,
ITestResult
- The ITestResult object.
tr
)

Method Summary

Modifier and TypeMethod and Description
public static Parameters.MethodParameters
newInstance(Map<String, String> params, ITestNGMethod testNGMethod, ITestContext context)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextback to summary
private final ITestContext context
currentTestMethodback to summary
private final Method currentTestMethod
parameterValuesback to summary
private final Object[] parameterValues
testResultback to summary
private final ITestResult testResult
xmlParametersback to summary
private final Map<String, String> xmlParameters

Constructor Detail

MethodParametersback to summary
public MethodParameters(Map<String, String> params, Map<String, String> methodParams)
MethodParametersback to summary
public MethodParameters(Map<String, String> params, Map<String, String> methodParams, Object[] pv, Method m, ITestContext ctx, ITestResult tr)
Parameters
params:Map<String, String>

parameters found in the suite and test tags

methodParams:Map<String, String>

parameters found in the include tag

pv:Object[]

parameter values to be used.

m:Method

the Method object.

ctx:ITestContext

The ITestContext object representing the current test

tr:ITestResult

- The ITestResult object.

Method Detail

newInstanceback to summary
public static Parameters.MethodParameters newInstance(Map<String, String> params, ITestNGMethod testNGMethod, ITestContext context)