/** * Returns default message (using in {@link ru.yandex.qatools.allure.events.TestCaseStatusChangeEvent} * if throwable not specified) * * @return default message */ @Override protected String getMessage() { return getStatus() == Status.FAILED ? "Test failed with unknown reason" : "Test broken with unknown reason"; }
/** * Sets throwable using fluent-api * * @param value to set * @return modified instance */ public TestCaseStatusChangeEvent withThrowable(Throwable value) { setThrowable(value); return this; } }
@Override public void onTestFailure(ITestResult iTestResult) { getLifecycle().fire(new TestCaseFailureEvent() .withThrowable(iTestResult.getThrowable()) ); fireFinishTest(); }
private Failure getFailure() { return new Failure() .withMessage(ExceptionUtils.getMessage(getThrowable())) .withStackTrace(ExceptionUtils.getStackTrace(getThrowable())); } }
@Override public void process(TestCaseResult testCase) { Status status = throwable instanceof AssertionError ? Status.FAILED : Status.BROKEN; testCase.setStatus(status); testCase.setFailure(getFailure()); }
public void fireTestCaseFailure(Throwable throwable) { if (throwable instanceof AssumptionViolatedException) { getLifecycle().fire(new TestCaseCanceledEvent().withThrowable(throwable)); } else { getLifecycle().fire(new TestCaseFailureEvent().withThrowable(throwable)); } }
@Override public void result(Result result) { if (match != null) { if (FAILED.equals(result.getStatus())) { this.excuteFailureCallback(); ALLURE_LIFECYCLE.fire(new StepFailureEvent().withThrowable(getError(result))); ALLURE_LIFECYCLE.fire(new TestCaseFailureEvent().withThrowable(getError(result))); currentStatus = FAILED; } else if (SKIPPED.equals(result.getStatus())) { ALLURE_LIFECYCLE.fire(new StepCanceledEvent()); if (PASSED.equals(currentStatus)) { //not to change FAILED status to CANCELED in the report ALLURE_LIFECYCLE.fire(new TestCasePendingEvent()); currentStatus = SKIPPED; } } ALLURE_LIFECYCLE.fire(new StepFinishedEvent()); match = null; } }
@Override public void onConfigurationFailure(ITestResult iTestResult) { if (isSuppressConfigEvent(iTestResult)) { return; } String suiteUid = getSuiteUid(iTestResult.getTestContext()); if (isAfterSuiteConfigMethod(iTestResult)) { String suiteTitle = getCurrentSuiteTitle(iTestResult.getTestContext()); getLifecycle().fire(new TestSuiteStartedEvent(suiteUid, suiteTitle).withTitle(suiteTitle)); } Throwable throwable = iTestResult.getThrowable(); createConfigEvent(iTestResult); getLifecycle().fire(new TestCaseFailureEvent().withThrowable(throwable)); fireFinishTest(); if (isAfterSuiteConfigMethod(iTestResult)) { getLifecycle().fire(new TestSuiteFinishedEvent(suiteUid)); } }