Search in sources :

Example 1 with TestResultItem

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

the class AbstractTestListener method onConfigurationFailure.

@Override
public void onConfigurationFailure(ITestResult result) {
    afterConfiguration(result);
    // failItem(result, Messager.CONFIG_FAILED);
    // String test = TestNamingUtil.getCanonicalTestName(result);
    // closeLogAppender(test);
    String errorMessage = getFailureReason(result);
    takeScreenshot(result, "CONFIGURATION FAILED - " + errorMessage);
    TestResultItem resultItem = createTestResult(result, TestResultType.FAIL, errorMessage, result.getMethod().getDescription());
    setConfigFailure(resultItem);
    super.onConfigurationFailure(result);
}
Also used : TestResultItem(com.qaprosoft.carina.core.foundation.report.TestResultItem)

Example 2 with TestResultItem

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

the class AbstractTestListener method skipItem.

private String skipItem(ITestResult result, Messager messager) {
    String test = TestNamingUtil.getCanonicalTestName(result);
    String errorMessage = getFailureReason(result);
    if (errorMessage.isEmpty()) {
        // identify is it due to the dependent failure or exception in before suite/class/method
        String[] methods = result.getMethod().getMethodsDependedUpon();
        // find if any parent method failed/skipped
        boolean dependentMethod = false;
        String dependentMethodName = "";
        for (ITestResult failedTest : result.getTestContext().getFailedTests().getAllResults()) {
            for (int i = 0; i < methods.length; i++) {
                if (methods[i].contains(failedTest.getName())) {
                    dependentMethodName = failedTest.getName();
                    dependentMethod = true;
                    break;
                }
            }
        }
        for (ITestResult skippedTest : result.getTestContext().getSkippedTests().getAllResults()) {
            for (int i = 0; i < methods.length; i++) {
                if (methods[i].contains(skippedTest.getName())) {
                    dependentMethodName = skippedTest.getName();
                    dependentMethod = true;
                    break;
                }
            }
        }
        if (dependentMethod) {
            errorMessage = "Test skipped due to the dependency from: " + dependentMethodName;
        } else {
            // Try to find error details from last configuration failure in this thread
            TestResultItem resultItem = getConfigFailure();
            if (resultItem != null) {
                errorMessage = resultItem.getFailReason();
            }
        }
    }
    String deviceName = getDeviceName();
    messager.info(deviceName, test, DateUtils.now(), errorMessage);
    EmailReportItemCollector.push(createTestResult(result, TestResultType.SKIP, errorMessage, result.getMethod().getDescription()));
    result.getTestContext().removeAttribute(SpecialKeywords.TEST_FAILURE_MESSAGE);
    return errorMessage;
}
Also used : ITestResult(org.testng.ITestResult) TestResultItem(com.qaprosoft.carina.core.foundation.report.TestResultItem)

Example 3 with TestResultItem

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

the class AbstractTestListener method createTestResult.

protected TestResultItem createTestResult(ITestResult result, TestResultType resultType, String failReason, String description) {
    String group = StringEscapeUtils.escapeHtml4(TestNamingService.getPackageName(result));
    String linkToLog = ReportContext.getTestLogLink();
    String linkToScreenshots = ReportContext.getTestScreenshotsLink();
    String test = StringEscapeUtils.escapeHtml4(TestNameResolverRegistry.get().resolve(result));
    TestResultItem testResultItem = new TestResultItem(group, test, description, resultType, linkToScreenshots, linkToLog, failReason);
    return testResultItem;
}
Also used : TestResultItem(com.qaprosoft.carina.core.foundation.report.TestResultItem)

Example 4 with TestResultItem

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

the class EmailReportGenerator method getTestResultsList.

private String getTestResultsList(List<TestResultItem> testResultItems) {
    if (testResultItems.size() > 0) {
        Collections.sort(testResultItems, new EmailReportItemComparator());
        String packageName = "";
        testResults = new StringBuilder();
        for (TestResultItem testResultItem : testResultItems) {
            if (!testResultItem.isConfig() && !packageName.equals(testResultItem.getPack())) {
                packageName = testResultItem.getPack();
                testResults.append(PACKAGE_TR.replace(PACKAGE_NAME_PLACEHOLDER, packageName));
            }
            testResults.append(getTestRow(testResultItem));
        }
    }
    return testResults != null ? testResults.toString() : "";
}
Also used : TestResultItem(com.qaprosoft.carina.core.foundation.report.TestResultItem)

Example 5 with TestResultItem

use of com.qaprosoft.carina.core.foundation.report.TestResultItem 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)

Aggregations

TestResultItem (com.qaprosoft.carina.core.foundation.report.TestResultItem)6 TestResultType (com.qaprosoft.carina.core.foundation.report.TestResultType)1 ITestResult (org.testng.ITestResult)1