I hope this scenario is bit confused me lot. I want to run a few test cases using junit or testng with different set of data from csv file. The code snippet i have tried is given below but it dint work,
private static CSVReader csvReader = null;
@BeforeClass
public static void setUp() {
csvReader = new CSVReader(new FileReader(fileName));
}
@Test
public void test1() {
.......
.......
System.out.println(csvReader[0]);
}
@Test
public void test2() {
.......
.......
System.out.println(csvReader[1]);
}
@Test
public void test3() {
.......
.......
System.out.println(csvReader[2]);
}
@Test
public void test4() {
.......
.......
System.out.println(csvReader[3]);
}
My problem is that i need to use data from each column in different test cases and i need to iterate all the test cases again if i have multiple rows in csv file. I have tried using Theories and Datapoints, but it works in a way that first cases runs with all rows in csv file and its moves to next test case and runs again with all rows in csv.
I want the solution to run test1() with first column of first row, test2() with second column of first row, test3() with third column of first row and test4() with fourth column of first row and then same need to be iterated with second row and so on. Is it possible to iterate the test cases like this ? As far i searched we can iterate a particular test cases in many ways. My question is, is this possible to iterate all the test in a class with one set of data and again reiterate the class with another set of data from csv.
Can we accomplish this using junit or testng? if so, please proved some sample code. Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire