I’m generating the extent report and I’m fetching the data from excel file. Condition is if the string fetched from excel is "Found" then my test should pass otherwise fail, but in this code it only fetches the data from the first row in the excel.
@Test
public void passTest() throws IOException {
File src = new File("F:\\drive f\\DemoReport.xlsx");
FileInputStream fis = new FileInputStream(src);
XSSFWorkbook wb = new XSSFWorkbook(fis);
XSSFSheet sheet1 = wb.getSheetAt(0);
int rowcount = sheet1.getLastRowNum();
for(int i=1;i<=rowcount;i++) {
String str = sheet1.getRow(i).getCell(2).getStringCellValue();
String str1 = sheet1.getRow(i).getCell(1).getStringCellValue();
double j = sheet1.getRow(i).getCell(3).getNumericCellValue();
fis.close();
String exp1 = "Found";
String exp2 = "Not Found";
if(str.equals(exp1)) {
logger=extent.createTest(str1);
Assert.assertTrue(true);
logger.log(Status.PASS, MarkupHelper.createLabel(str1 + " found at index " + j, ExtentColor.GREEN));
}
else if(str.equals(exp2)) {
logger=extent.createTest(str1);
Assert.assertTrue(true);
logger.log(Status.FAIL, MarkupHelper.createLabel(str1 + "is not found", ExtentColor.RED));
}
}
}