2

I am using testng dataprovider(using xlsx) for parametrization, I have 20 parameters for 1 method and some of these are optional so not specifying values for optional parameters. When I run my test I am getting below error:

org.testng.internal.reflect.DataProviderMethodMatcher.getConformingArguments.

It is giving exception:

'Data provider mismatch'(org.testng.internal.reflect.MethodMatcherException:)

In console I can see it's reading arguments and throws exception exactly at the parameter for which I haven't provide value and kept blank in xls.

Is it mandatory to provide values for all the parameters when using testng dataprovider?

1

It is mandatory that the DataProvider returns the same number of arguments that the method expects.

This is in line with TestNG documentation regarding DataProvider return types:

An array of array of objects (Object[][]) where the first dimension's size is the number of times the test method will be invoked and the second dimension size contains an array of objects that must be compatible with the parameter types of the test method.

The message "Data provider mismatch" might be misleading, as indicated by this discussion on TestNG GitHub site, but the basic idea is that the number of elements in the particular array of objects does not match the method signature.

This can be fixed by making sure any blank values in test data are still added to the Object array, for example, as null values (if null values are expected by the test method for the "optional" parameters).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.