extentreports-java icon indicating copy to clipboard operation
extentreports-java copied to clipboard

Test case status appears to be fail, if i removeTestCase that was fail in first attempt but gets passed in second retry

Open QuasarsResources opened this issue 7 years ago • 1 comments

public class ExtentReport { public static ExtentHtmlReporter htmlReporter; public static ExtentReports extent; public static ExtentTest deviceNameInReport; public static ExtentTest testCase;

Logger logger = LoggerFactory.getLogger(ExtentReport.class);

public void startReport() {
	logger.info("\t\tInitializing Extent Report			");
	htmlReporter = new ExtentHtmlReporter(System.getProperty("user.dir") + "/ExtentReport.html");
	extent = new ExtentReports();
	extent.attachReporter(htmlReporter);
	extent.setSystemInfo("Host Name", "Quasars Project");
	extent.setSystemInfo("Environment", "Continuous Regression");
	extent.setSystemInfo("User Name", "Quasars);

	htmlReporter.config().setDocumentTitle("Quasars Automation");
	htmlReporter.config().setReportName("Quasars Test Automation Report");
	htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
	htmlReporter.config().setTheme(Theme.STANDARD);
}

public static void startTestCase(String testCaseName) {
	testCase = deviceNameInReport.createNode(testCaseName);
}

public static void endTestCase() {
	extent.flush();
}

}


public class Retry implements IRetryAnalyzer { private int retryCount = 0; private int maxRetryCount = 2;

// Below method returns 'true' if the test method has to be retried else 'false'
// and it takes the 'Result' as parameter of the test method that just ran
public boolean retry(ITestResult result) {

	if (retryCount < maxRetryCount) {
		ExtentReport.extent.removeTest(ExtentReport.testCase); // DELETING RETRY CASES FROM THE REPORT
screen shot 2018-04-11 at 11 16 40 am
		System.out.println("Retrying test " + result.getName() + " with status "
				+ getResultStatusName(result.getStatus()) + " for the " + (retryCount + 1) + " time(s).");
		retryCount++;
		return true;
	}
	return false;
}

public String getResultStatusName(int status) {
	String resultName = null;
	if (status == 1)
		resultName = "SUCCESS";
	if (status == 2)
		resultName = "FAILURE";
	if (status == 3)
		resultName = "SKIP";
	return resultName;
}

}

QuasarsResources avatar Apr 11 '18 06:04 QuasarsResources

I am unable to reproduce. Can you share a small snippet or project that I can use to reproduce?

anshooarora avatar Apr 17 '18 18:04 anshooarora