Question : The @test
method will run for each row from the excel sheet when I use data provider?
Ans : Yes, it will run for each set of data. It depends on you how you read data from excel file.
Take this as an example :
@DataProvider(name = "test1")
public Object[][] createData1() {
return new Object[][] {
{ "Cedric", new Integer(36) },
{ "Anne", new Integer(37)},
};
@Test(dataProvider = "test1")
public void verifyData1(String n1, Integer n2) {
System.out.println(n1 + " " + n2);
}
The verifyData1 method will be running two times irrespective of any set of data, irrespective of whether first one failed or not.
Q : What happens when one of the row failed to process?
Ans : Test case would be failed for that particular row , and execution will continue by reading the next set of data from excel.
Q. Does it run the rest of the rows after this failure?
Ans : Ideally it should , now again it depends whether you have @AfterMethod
with you or not.
Q. Do I have to re-initiate the selenium webdriver and login method again when it fails?
Ans : No. It's better if you are initializing driver in @BeforeMethod
, because before method would be running prior to each set of data which is generated by dataprovider.
Hope this will help.