I'm new to TestNG framework. I'm planning to use DataProvider to pass the list of form values from the excel sheet.
Let's say add product from the list in excel sheet. The @test method will run for each row from the excel sheet when I use data provider?
What happens when one of the row failed to process? Does it run the rest of the rows after this failure? Do I have to re-initiate the selenium webdriver and login method again when it fails? I do not want to re initiate the webdriver for each failure..
My current application will retain the session even when the browser closes.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With