Open SSINGHPR opened 10 months ago
@SSINGHPR Hello, Did you find any workaround for this issue ?
I have figured out a temporary workaround for this. You can parse the retryCount variable from RetryAnalyzer class to the base class and if the scenario is failed and retryCount is less than maxRetries then you can remove that scenario.
Can you please share the code you’re taking about that way I can give a try and see if this works in my framework. Thanks In Advance.
Thanks Sumit,
Indeed it does remove the failed test however for some reason the report still shows the feature as failed which makes the report look inaccurate still. Hope they will just fix this one day.
[image: image.png]
Thanks, Sanjay.
On Sun, Sep 8, 2024 at 12:31 AM Sumit-Systango @.***> wrote:
@SSINGHPR https://github.com/SSINGHPR Sure,
Use below code in @after https://github.com/after hook....
@after https://github.com/after(order = 0) public void quitBrowser(Scenario scenario) throws IOException { //validate if scenario has failed
if(scenario.isFailed()) { if(RetryAnalyzer.isRetried()){ ExtentService.getInstance().removeTest(ExtentCucumberAdapter.getCurrentScenario()); } else { byte[] screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); scenario.attach(screenshot, "image/png", "Failure screenshot"); } } driver.quit();
}
And this is how Retry class should look like...
import org.testng.IRetryAnalyzer; import org.testng.ITestResult; import java.util.HashMap; import java.util.Map;
public class RetryAnalyzer implements IRetryAnalyzer { public static int retryCount = 0; public static final int maxRetryCount = 2;
// Store retried tests and their final status public static final Map<String, Boolean> retryStatus = new HashMap<>();
@Override public boolean retry(ITestResult result) {
if (retryCount < maxRetryCount) { retryCount++; return true; } else { retryStatus.put(result.getName(), result.isSuccess()); return false; }
}
public static boolean isRetried(){ if(retryCount<maxRetryCount){ return true; } else{ return false; } }
public static Map<String, Boolean> getRetryStatus() { return retryStatus; }
}
— Reply to this email directly, view it on GitHub https://github.com/grasshopper7/extentreports-cucumber7-adapter/issues/38#issuecomment-2336554010, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ4C62DAOOAXERHFCV2K3OLZVPOMZAVCNFSM6AAAAABM4B46EGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZWGU2TIMBRGA . You are receiving this because you were mentioned.Message ID: @.*** com>
Hi,
I am using [RetryAnalyzer] to re-run the failed TestNG tests by passing the listener in testng.xml
however in the extent report It ends up having both the failed scenarios. I saw the extentReports has the config to keep the last retried however it did not work. any idea where should I put this inorder to work ? extentReports.isKeepLastRetryOnly(); I also tried this below logic I found however it did not help either : https://stackoverflow.com/questions/51420504/retry-analyzer-and-extent-report https://stackoverflow.com/questions/67368492/how-to-remove-first-attempt-of-failed-test-cases-from-extent-report-when-using-r
Also saw long time ago this bug was reported with extent developers and seems like they did fix couple of years back however I am still not able to achieve only keeping the last retried test so that the count of total tests doesn't get messed up in the report with retry logic. Thanks so much in advance for taking time to look into this and would very much appreciate the help to resolve this.
For example : In the below screenshot the test "Verify Failed App Login] [1] was marked as skipped since it failed and then was reran by the RetryAnalyzer logic however in the extent report both of those shows as failed. How can I achieve to have only one failed test name after retry and do not account the skipped one in the report.