I have created an excel of 10 rows×10 columns.I want dataprovider to return only those rows,which has a value "Y" in the respective column.This will be used when a Test suite will be executed and test cases to be executed will be flagged as "Y".
Need your help.
Thanks in advance.
Please find my code below.: ......................................
@Test(dataProvider = "testdata")
public void Create(String TC_ID, String TC_Name, String Username, String Password, String aaa, String bbb, String ccc, String ddd, String eee, String fff, String ggg, String hhh, String iii, String jjj, String kkk, String lll) throws InterruptedException {
if (lll.equals("Y")) {
} else {
System.out.println("Testcases not flagged for Automation.." + "......." + TC_ID + "...." + TC_Name);
throw new SkipException("...Skipped....");
}
}
// @AfterMethod
//
// public void tearDown() {
// driver.quit();
// }
@DataProvider(name = "testdata")
public String[][] readExcel() throws BiffException, IOException {
File f = new File("C:/Test input/Test.xls");
Workbook wb = Workbook.getWorkbook(f);
Sheet s = wb.getSheet("Sheet1");
int rows = s.getRows();
int columns = s.getColumns();
// System.out.println(rows);
// System.out.println(columns);
String inputData[][] = new String[rows - 1][columns];
for (int i = 1; i < rows; i++) {
for (int j = 0; j < columns; j++) {
Cell c = s.getCell(j, i);
inputData[i - 1][j] = c.getContents();
}
}
return inputData;
}
}
...................................... I want to add a column to my excel test data,where the flag(Y/N) will be mentioned.Only Y flagged test cases will be executed. But here in my code Y flagged tcases are getting executed and others are getting skipped and those skipped testcases are also getting added to the testng report which I dont want.
Could anyone help me on that?