Search in sources :

Example 1 with TestResultType

use of com.qaprosoft.carina.core.foundation.report.TestResultType in project carina by qaprosoft.

the class EmailReportGenerator method getSuiteResult.

public static TestResultType getSuiteResult(List<TestResultItem> ris) {
    int passed = 0;
    int failed = 0;
    int failedKnownIssue = 0;
    int skipped = 0;
    int skipped_already_passed = 0;
    for (TestResultItem ri : ris) {
        if (ri.isConfig()) {
            continue;
        }
        switch(ri.getResult()) {
            case PASS:
                passed++;
                break;
            case FAIL:
                failed++;
                break;
            case SKIP:
                skipped++;
                break;
            case SKIP_ALL:
                // do nothing
                break;
            default:
                // do nothing
                break;
        }
    }
    TestResultType result;
    if (passed == 0 && failed == 0 && skipped == 0 && skipped_already_passed > 0) {
        // it was re-run of the suite where all tests passed during previous run
        result = TestResultType.SKIP_ALL_ALREADY_PASSED;
    } else if (passed > 0 && failedKnownIssue == 0 && failed == 0 && skipped == 0) {
        result = TestResultType.PASS;
    } else if (passed >= 0 && failedKnownIssue > 0 && failed == 0 && skipped == 0) {
        result = TestResultType.PASS_WITH_KNOWN_ISSUES;
    } else if (passed == 0 && failed == 0 && skipped > 0) {
        result = TestResultType.SKIP_ALL;
    } else if (passed >= 0 && failed == 0 && skipped > 0) {
        result = TestResultType.SKIP;
    } else {
        result = TestResultType.FAIL;
    }
    result.setPassed(passed);
    result.setFailed(failed + failedKnownIssue);
    result.setSkipped(skipped);
    return result;
}
Also used : TestResultType(com.qaprosoft.carina.core.foundation.report.TestResultType) TestResultItem(com.qaprosoft.carina.core.foundation.report.TestResultItem)

Example 2 with TestResultType

use of com.qaprosoft.carina.core.foundation.report.TestResultType 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);
    }
}
Also used : EmailReportGenerator(com.qaprosoft.carina.core.foundation.report.email.EmailReportGenerator) TestResultType(com.qaprosoft.carina.core.foundation.report.TestResultType) SkipException(org.testng.SkipException)

Aggregations

TestResultType (com.qaprosoft.carina.core.foundation.report.TestResultType)2 TestResultItem (com.qaprosoft.carina.core.foundation.report.TestResultItem)1 EmailReportGenerator (com.qaprosoft.carina.core.foundation.report.email.EmailReportGenerator)1 SkipException (org.testng.SkipException)1