Reputation: 1682
I'm new on this so this isn't so obvious for me. I'm trying to implement IRetryAnalyzer from testNG, to re run the test cases that failed.
And this is what I've done, but can't make it work. Note all this code I've copied form the internet.
public class Retry implements IRetryAnalyzer {
private int retryCount = 0;
private int maxRetryCount = 2;
@Override
public boolean retry(ITestResult result) {
if (retryCount < maxRetryCount) {
System.out.println("Entre");
retryCount++;
return true;
}
return false;
}
Here is my test method were it should fail and re run the test.
@Parameters({ "nombrePlan", "nombreBuild", "nomTL_verificacionUIHomePageIssuer" })
@Test(retryAnalyzer = Retry.class)
public void verificacionUIHomePageIssuer(String nombrePlan, String nombreBuild, String nomTL_verificacionUIHomePageIssuer) throws Exception {
HomePageIssuer homePage = new HomePageIssuer(driver);
//Assert.assertTrue(homePage.validacionLogin(), homePage.getError());
Assert.assertTrue(false);
}
The thing is that when I run it doesn't work the driver closes and the test never starts again. Any help would be appreciated. Thanks in advance.
Upvotes: 0
Views: 1338
Reputation: 8531
Based on comments, @BeforeTest was being used for driver initalization and hence Retry wasn't invoking it again.
BeforeTest will only be called once for your entire tag. Try using @beforemethod, but then this would init after every testcase.
Upvotes: 1