cbeust/testng — pull request #456 by pertu (2013-10-25 21:43:05+00:00)
Title: Fix Invoker.injectParameters() vararg handling

# Problem
Data provider parameter injection doesn't work for methods with mixed non-vararg & vararg parameters

# Example

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

import java.util.Arrays;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;

public class VarargsDemoTest {
// works fine; ugly & error-prone code
@Test(dataProvider = "testDataProvider")
public void testService1(String... testData) {
if (testData.length == 0) {
fail("Test data is empty");
}
final String query = testData[0];
final String[] expectedResults = Arrays.copyOfRange(testData, 1, testData.length);
for (int i = 0; i < expectedResults.length; ++i) {
assertEquals(processQuery(query, i), expectedResults[i]);
}
}

// works fine, params (number of results) are hardcoded
@Test(dataProvider = "testDataProvider")
public void testService2(String query, String expected0, String expected1) {
assertEquals(processQuery(query, 0), expected0);
assertEquals(processQuery(query, 1), expected1);
}

// doesn't work for now (works with patch)
@Test(dataProvider = "testDataProvider")
public void testService3(String query, String... expectedResults) {
for (int i = 0; i < expectedResults.length; ++i) {
assertEquals(processQuery(query, i), expectedResults[i]);
}
}

@DataProvider(name = "testDataProvider")
public Object[][] testDataProvider() {
return new Object[][] {
new String[]{ "abc", "abc_result#0", "abc_result#1" },
new String[]{ "cba", "cba_result#0", "cba_result#1" },
};
}

private String processQuery(String query, int resultNum) {
return query + "_result#" + resultNum;
}
}
```