我有2个excel工作表,我正在使用testNg断言比较单元格值。 以下是sheet1和sheet2中的值
Sheet1 Sheet2
sachin sachin
david david
nancy nancy
winter winter
int rowCount = xlib.getRowCount("Sheet1");
int rowCount1 = xlib.getRowCount("Sheet2");
for (int i = 34; i<=rowCount;i++)
{
String compair1= xlib.getExcelData("Sheet1", i, 5);
System.out.println(compair1);
for (int j = 34; j<=rowCount1;j++)
{
String compair2=xlib.getExcelData("Sheet2", j, 5);
System.out.println(compair2);
Assert.assertEquals(compair1, compair2);
System.out.println(“成功比较”);
}
}
}
}
结果:-
sachin
sachin
compared successfully
david
FAILED: Totalcompare
java.lang.AssertionError: expected [david] but found [sachin]
预期结果 结果:-
sachin
sachin
compared successfully
david
david
compared successfully
nancy
nancy
compared successfully
winter
winter
compared successfully
passed: Totalcompare