cbeust/testng — Issue #122: Array in dataProvider not matching Varargs parameter
Author: dklaus
Created: 2011-11-03 22:31:01+00:00
State: open

I have hit an issue that I believe was introduced in a recent version of TestNG. If a dataProvider contains an array of information and the test method using it has a Varags parameter, TestNG is throwing a IllegalArgumentException. The example I put together is as follows:

```
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class displayTextTest
{
@DataProvider
public Object[][] testStrings()
{
return new Object[][] {
new Object[] {new String[] { "one" } },
new Object[] {new String[] { "two" } },
new Object[] {new String[] { "three", "four" } } };
}

@Test(dataProvider = "testStrings")
public void goodTest(String[] strings)
{
for (String item : strings)
{
System.out.println("An item is \"" + item + "\"");
}
}

@Test(dataProvider = "testStrings")
public void badTest(String... strings)
{
for (String item : strings)
{
System.out.println("An item is \"" + item + "\"");
}
}
}
```
The goodTest will work and the badTest will throw an IllegalArgumentException. This is new behaviror, as the actual test this is based on worked prior to TestNG 6.3.0.20111017_2337 and now thows the exception in this version.