I canβt check it right now, but I think if you call a method or constructor with variable arguments, you should call it with an array instead of a list of variables.
If I'm right, then this should work:
@Parameters public static Collection<Object[]> data() { return Arrays.asList(new Object[][] { {0, new String[]{"hello", "goodbye"}}, {1, new String[]{"farewell"}} }); }
Some explanation
At the source code level, we can write
test = ExampleParamTest(0, "one", "two");
The compiler will convert this to an array of strings. JUnit uses the reflection and call API, and from this point of view, the signature of the constructors
public ExampleParamTest(int i, String[] strings);
So, to call the constructor - and what JUnit does internally - you need to pass an integer and an array of String.
Andreas_D
source share