test
@RunWith(JUnitParamsRunner.class) public class ParamTest { @Test @FileParameters("src/test/resources/param.csv") public void test(int size, String[] arr) { assertEquals(size, arr.length); } }
and the file from which to read:
2, asdf, asdf
in this case, the code works, it reads value 2 as int. other values fall into the array of strings.
Change the arguments and order of values in the file
@RunWith(JUnitParamsRunner.class) public class ParamTest { @Test @FileParameters("src/test/resources/param.csv") public void test(String[] arr, int size) { assertEquals(size, arr.length); } }
File:
"asdf, asdf", 2
We divide according to the csv file format in quotes a single field, the code gives an error
java.lang.IllegalArgumentException: wrong number of arguments
Those. as far as I understand, if a primitive goes, and then an array, then all the values up to the end of the file to parse into this array, if, on the contrary, you cannot specify where the array ends in the file or the JunitParams functionality does not allow this?