use of com.qaprosoft.carina.core.foundation.report.email.EmailReportGenerator in project carina by qaprosoft.
the class AbstractTest method executeAfterTestSuite.
@AfterSuite(alwaysRun = true)
public void executeAfterTestSuite(ITestContext context) {
try {
if (Configuration.getDriverMode() == DriverMode.SUITE_MODE) {
LOGGER.debug("Deinitialize driver(s) in UITest->AfterSuite.");
quitDrivers();
}
// clean temp artifacts directory
ReportContext.removeTempDir();
HtmlReportGenerator.generate(ReportContext.getBaseDir().getAbsolutePath());
String browser = getBrowser();
String deviceName = getDeviceName();
// String suiteName = getSuiteName(context);
String title = getTitle(context);
TestResultType testResult = EmailReportGenerator.getSuiteResult(EmailReportItemCollector.getTestResults());
String status = testResult.getName();
title = status + ": " + title;
String env = "";
if (!Configuration.isNull(Parameter.ENV)) {
env = Configuration.get(Parameter.ENV);
}
if (!Configuration.get(Parameter.URL).isEmpty()) {
env += " - <a href='" + Configuration.get(Parameter.URL) + "'>" + Configuration.get(Parameter.URL) + "</a>";
}
ReportContext.getTempDir().delete();
// Update JIRA
Jira.updateAfterSuite(context, EmailReportItemCollector.getTestResults());
// generate and send email report by Zafira to test group of people
String emailList = Configuration.get(Parameter.EMAIL_LIST);
String failureEmailList = Configuration.get(Parameter.FAILURE_EMAIL_LIST);
String senderEmail = Configuration.get(Parameter.SENDER_EMAIL);
String senderPassword = Configuration.get(Parameter.SENDER_PASSWORD);
// Generate and send email report using regular method
EmailReportGenerator report = new EmailReportGenerator(title, env, Configuration.get(Parameter.APP_VERSION), deviceName, browser, DateUtils.now(), DateUtils.timeDiff(startDate), getCIJobReference(), EmailReportItemCollector.getTestResults(), EmailReportItemCollector.getCreatedItems());
String emailContent = report.getEmailBody();
if (!R.ZAFIRA.getBoolean("zafira_enabled")) {
// Do not send email if run is running with enabled Zafira
EmailManager.send(title, emailContent, emailList, senderEmail, senderPassword);
if (testResult.equals(TestResultType.FAIL) && !failureEmailList.isEmpty()) {
EmailManager.send(title, emailContent, failureEmailList, senderEmail, senderPassword);
}
}
// Store emailable report under emailable-report.html
ReportContext.generateHtmlReport(emailContent);
printExecutionSummary(EmailReportItemCollector.getTestResults());
LOGGER.debug("Generating email report...");
TestResultType suiteResult = EmailReportGenerator.getSuiteResult(EmailReportItemCollector.getTestResults());
switch(suiteResult) {
case SKIP_ALL:
Assert.fail("All tests were skipped! Analyze logs to determine possible configuration issues.");
break;
case SKIP_ALL_ALREADY_PASSED:
LOGGER.info("Nothing was executed in rerun mode because all tests already passed and registered in Zafira Repoting Service!");
break;
default:
}
LOGGER.debug("Finish email report generation.");
} catch (Exception e) {
LOGGER.error("Exception in AbstractTest->executeAfterSuite: " + e.getMessage());
e.printStackTrace();
}
}
use of com.qaprosoft.carina.core.foundation.report.email.EmailReportGenerator in project carina by qaprosoft.
the class CarinaListener method onFinish.
@Override
public void onFinish(ISuite suite) {
LOGGER.debug("CarinaListener->onFinish(ISuite suite)");
try {
// TODO: quitAllDivers forcibly
// clean temp artifacts directory
ReportContext.removeTempDir();
// HtmlReportGenerator.generate(ReportContext.getBaseDir().getAbsolutePath());
String browser = getBrowser();
String deviceName = getFullDeviceName();
// String suiteName = getSuiteName(context);
String title = getTitle(suite.getXmlSuite());
TestResultType testResult = EmailReportGenerator.getSuiteResult(EmailReportItemCollector.getTestResults());
String status = testResult.getName();
title = status + ": " + title;
String env = "";
if (!Configuration.isNull(Parameter.ENV)) {
env = Configuration.get(Parameter.ENV);
}
if (!Configuration.get(Parameter.URL).isEmpty()) {
env += " - <a href='" + Configuration.get(Parameter.URL) + "'>" + Configuration.get(Parameter.URL) + "</a>";
}
ReportContext.getTempDir().delete();
// EmailReportItemCollector.getTestResults());
LOGGER.debug("Generating email report...");
// Generate emailable html report using regular method
EmailReportGenerator report = new EmailReportGenerator(title, env, Configuration.get(Parameter.APP_VERSION), deviceName, browser, DateUtils.now(), EmailReportItemCollector.getTestResults(), EmailReportItemCollector.getCreatedItems());
String emailContent = report.getEmailBody();
// Store emailable report under emailable-report.html
ReportContext.generateHtmlReport(emailContent);
printExecutionSummary(EmailReportItemCollector.getTestResults());
ReportContext.setCustomTestDirName("run_summary");
TestResultType suiteResult = EmailReportGenerator.getSuiteResult(EmailReportItemCollector.getTestResults());
switch(suiteResult) {
case SKIP_ALL:
Assert.fail("All tests were skipped! Analyze logs to determine possible configuration issues.");
break;
case SKIP_ALL_ALREADY_PASSED:
LOGGER.info("Nothing was executed in rerun mode because all tests already passed and registered in Zafira Repoting Service!");
break;
default:
}
LOGGER.debug("Finish email report generation.");
} catch (Exception e) {
LOGGER.error("Exception in CarinaListener->onFinish(ISuite suite)", e);
}
}
Aggregations