I am using dataProvider to pass parameters to a test method. Say
dataProvider method passes 10 data sets and it fails 3 times. And now
I just want to run the test method only 3 times with the failed data,
am struggling a bit to make sure only that happens and does not run 10
times again. Please guide me in this.
In one single test method I have both passed and failed test cases
present at a time hence when ever I invoke this perticular method I
have with me both the passed and failed report generated at the same
time. But the issue is, when ever I specifically want to run the
Failed test cases from the testng-failed.xml I come across again with
all the cases(passed as well as failed cases), which I do not want. I
only want to get the failed cases here only not the passed one even
though it is in the same method.
For eg ::
public class BaseTest{
String id;
BaseTest(String id) {
this.id = id;
}
@Test(dataProvider="CheckTest")
public void testGenX(String testMe) {
System.out.println("id=" + id +" testMe="+ testMe);
if("A".equals(id))
Assert.assertEquals("james", testMe); //ListenerTest fails for
james
else {
Assert.assertEquals("andrew", testMe); //AnotherTest fails for
andrew
}
}
@DataProvider(name="CheckTest")
public Object[][] permanentGiver() {
return new Object[][] {
{"andrew"}, {"james"},
{"andrew"}, {"james"}
};
}
}
Result is::
===============================================
Default test
Tests run: 4, Failures: 2, Skips: 0
===============================================
now when I am running the testng-failure.xml for the fail result. I
again come across the same result(both the fail as well as the pass).
But I want only the fail result to execute. Kindly give a solution.