Have a look at the junitparams project, especially this example. It will show you how to use a CSV file for parameter input. Here's a short example:
My test.csv file:
1, one
2, two
3, three
My test:
package com.stackoverflow.sourabh.example;
import static org.junit.Assert.assertTrue;
import junitparams.FileParameters;
import junitparams.JUnitParamsRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(JUnitParamsRunner.class)
public class FileReadingParameterizedTest {
@Test
@FileParameters("src/test/resources/test.csv")
public void testWithCSV(int number, String name) {
assertTrue(name + " is not at least two", number >= 2);
}
}
Obviously the first test will fail, producing the error message one is not at least two.