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 classStore the result of parameterTypes and optionalValues after filter out injected typesstatic classA parameter passing helper class. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final List<Class<? extends Annotation>> static final StringDeprecated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanareAllOptionalValuesNull(String[] optionalValues) private static booleanprivate static voidcheckParameterTypes(String methodName, Class<?>[] parameterTypes, String methodAnnotation, String[] parameterNames) 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@ConfigurationMethod.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.FilterOutInjectedTypesResultfilterOutInjectedTypesFromOptionalValues(Class<?>[] parameterTypes, String[] optionalValues) Remove injected types from parameterTypes and optionalValuesprivate static IDataProviderMethodfindDataProvider(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 IDataProviderMethodfindDataProvider(ITestObjectFactory objectFactory, Object instance, ITestClass clazz, ConstructorOrMethod m, IAnnotationFinder finder, ITestContext context) private static IDataProvidablefindDataProviderInfo(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 Stringstatic ParameterHolderhandleParameters(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.static ParameterHolderhandleParameters(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.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 booleanisDataProviderClassEmpty(ITestAnnotation annotation) private static booleanisDataProviderNameEmpty(ITestAnnotation annotation) private static booleanisDynamicDataProviderClassEmpty(ITestAnnotation annotation) private static IDataProvidablemerge(ITestAnnotation methodLevel, ITestAnnotation classLevel) private static StringprettyFormat(List<Class<?>> classes) private static Class<? extends Annotation> private static booleanvalidParameters(String methodAnnotation, Class<?>[] parameterTypes)
-
Field Details
-
NULL_VALUE
Deprecated.- 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, ITestNGMethod currentTestMethod, IAnnotationFinder finder, XmlSuite xmlSuite, ITestContext ctx, ITestResult testResult) Creates the parameters needed for the specified@ConfigurationMethod.- Parameters:
m- the configuraton methodcurrentTestMethod- the current @Test method ornullif 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
-
findDataProvider
private static IDataProviderMethod findDataProvider(ITestObjectFactory objectFactory, 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
-
isDynamicDataProviderClassEmpty
-
isDataProviderNameEmpty
-
findDataProvider
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) -
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(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:
- An Iterator over the values for each parameter of this method.
-
handleParameters
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:
- 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 forNoInjectionannotation- Parameters:
parameterValues- parameter values from a data providermethod- method to be invokedcontext- test context- Throws:
TestNGException
-