Consider the case below:
@BeforeMethod(firstTimeOnly=true)
public void StartDriver()
{
System.out.println("Start Driver");
}
@AfterMethod(lastTimeOnly=true)
public void stopDriver()
{
System.out.println("Stop Driver");
}
@Test
public void TestRetry()
{
Assert.assertTrue(false,"TestRetry Failed");
}
If I use TestNG's IRetryAnalyzer to rerun the above case, the StartDriver & stopDriver are called for the actual first run, while none of the two is called for the Second(retry) time.
[testng] Start Driver
[testng] [Status]:TestRetry2_FAIL
[testng] Stop Driver
[testng] Going to retry test case: TestRetry()
[testng] [Status]:TestRetry2_FAIL
I am using TestNG 6.9.4 & this works fine(i.e start & stop are called for both first time & for the retry execution) if firstTimeOnly & lastTimeOnly are not mentioned.
Any help would be deeply appreciated.