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
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;
}
public class ExtentReport { public static ExtentHtmlReporter htmlReporter; public static ExtentReports extent; public static ExtentTest deviceNameInReport; public static ExtentTest testCase;
}
public class Retry implements IRetryAnalyzer { private int retryCount = 0; private int maxRetryCount = 2;
}