Class Parameters


  • public class Parameters
    extends java.lang.Object
    Methods that bind parameters declared in testng.xml to actual values used to invoke methods.
    • Constructor Detail

      • Parameters

        public Parameters()
    • Method Detail

      • createInstantiationParameters

        public static java.lang.Object[] createInstantiationParameters​(java.lang.reflect.Constructor ctor,
                                                                       java.lang.String methodAnnotation,
                                                                       IAnnotationFinder finder,
                                                                       java.lang.String[] parameterNames,
                                                                       java.util.Map<java.lang.String,​java.lang.String> params,
                                                                       XmlSuite xmlSuite)
        Creates the parameters needed for constructing a test class instance.
      • createConfigurationParameters

        public static java.lang.Object[] createConfigurationParameters​(java.lang.reflect.Method m,
                                                                       java.util.Map<java.lang.String,​java.lang.String> params,
                                                                       java.lang.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 method
        currentTestMethod - 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 - the annotation finder
      • getInjectedParameter

        @Deprecated
        public static java.lang.Object getInjectedParameter​(java.lang.Class<?> c,
                                                            java.lang.reflect.Method method,
                                                            ITestContext context,
                                                            ITestResult testResult)
        Deprecated.
        - This method stands deprecated as of TestNG v6.11. There are no alternatives.
      • convertType

        public static <T> T convertType​(java.lang.Class<T> type,
                                        java.lang.String value,
                                        java.lang.String paramName)
      • handleParameters

        public static ParameterHolder handleParameters​(ITestNGMethod testMethod,
                                                       java.util.Map<java.lang.String,​java.lang.String> allParameterNames,
                                                       java.lang.Object instance,
                                                       Parameters.MethodParameters methodParams,
                                                       XmlSuite xmlSuite,
                                                       IAnnotationFinder annotationFinder,
                                                       java.lang.Object fedInstance,
                                                       java.util.Collection<IDataProviderListener> dataProviderListeners)
        If the method has parameters, fill them in. Either by using a @DataProvider if any was provided, or by looking up in testng.xml
        Returns:
        An Iterator over the values for each parameter of this method.
      • handleParameters

        public static ParameterHolder handleParameters​(ITestNGMethod testMethod,
                                                       java.util.Map<java.lang.String,​java.lang.String> allParameterNames,
                                                       java.lang.Object instance,
                                                       Parameters.MethodParameters methodParams,
                                                       XmlSuite xmlSuite,
                                                       IAnnotationFinder annotationFinder,
                                                       java.lang.Object fedInstance,
                                                       java.util.Collection<IDataProviderListener> dataProviderListeners,
                                                       java.lang.String annotationName)
        If the method has parameters, fill them in. Either by using a @DataProvider if any was provided, or by looking up in testng.xml
        Returns:
        An Iterator over the values for each parameter of this method.
      • injectParameters

        public static java.lang.Object[] injectParameters​(java.lang.Object[] parameterValues,
                                                          java.lang.reflect.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 - parameter values from a data provider
        method - method to be invoked
        context - test context
        Throws:
        TestNGException
      • getParametersFromIndex

        public static java.lang.Object[] getParametersFromIndex​(java.util.Iterator<java.lang.Object[]> parametersValues,
                                                                int index)