Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove Retried scenarios from the report - testng #45

Open
arvinder06 opened this issue Sep 19, 2021 · 1 comment
Open

How to remove Retried scenarios from the report - testng #45

arvinder06 opened this issue Sep 19, 2021 · 1 comment

Comments

@arvinder06
Copy link

I am using org.testng Interface IRetryAnalyzer to retry the failed scenarios. I am able to remove the scenarios from testng context, however, the extent report still shows all the entries for retried scenarios:

@Override
public void onFinish(ITestContext context) {
    Iterator<ITestResult> skippedTestCases = context.getSkippedTests().getAllResults().iterator();
    while (skippedTestCases.hasNext()) {
        ITestResult skippedTestCase = skippedTestCases.next();
        ITestNGMethod method = skippedTestCase.getMethod();
        if (context.getSkippedTests().getResults(method).size() > 0) {
            System.out.println("Removing:" + skippedTestCase.getTestClass().toString());
            skippedTestCases.remove();
        }
    }
}

Test runner sample code:

import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;

@CucumberOptions(
        plugin = {
                "com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:",

How can I remove the entry for retried scenarios in the final report and have only one (latest) entry of the test case in the report. I am using 2.8.1

@grasshopper7
Copy link
Owner

Hi... What u r trying to achieve is not possible with the current code. The adapter code will need to be considerably modified to only keep the latest test details.

U can use the rerun plugin of cucumber to further process failed scenarios -> https://github.com/cucumber/cucumber-jvm/blob/main/core/src/main/java/io/cucumber/core/plugin/RerunFormatter.java. U can generate merged reports by referring to this article - https://ghchirp.tech/2882/. U will need extra runner to for this technique.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants