Search in sources :

Example 6 with Status

use of io.cucumber.plugin.event.Status in project cucumber-jvm by cucumber.

the class TestCaseResultObserver method assertTestCasePassed.

public void assertTestCasePassed(Supplier<Throwable> testCaseSkipped, Function<Throwable, Throwable> testCaseSkippedWithException, Function<List<Suggestion>, Throwable> testCaseWasUndefined, Function<Throwable, Throwable> testCaseWasPending) {
    Status status = result.getStatus();
    if (status.is(PASSED)) {
        return;
    }
    Throwable error = result.getError();
    if (status.is(SKIPPED) && error == null) {
        Throwable throwable = testCaseSkipped.get();
        throw new TestCaseFailed(throwable);
    } else if (status.is(SKIPPED) && error != null) {
        Throwable throwable = testCaseSkippedWithException.apply(error);
        throw new TestCaseFailed(throwable);
    } else if (status.is(UNDEFINED)) {
        Throwable throwable = testCaseWasUndefined.apply(suggestions);
        throw new TestCaseFailed(throwable);
    } else if (status.is(PENDING)) {
        Throwable throwable = testCaseWasPending.apply(error);
        throw new TestCaseFailed(throwable);
    }
    requireNonNull(error, "result.error=null while result.status=" + result.getStatus());
    throw new TestCaseFailed(error);
}
Also used : Status(io.cucumber.plugin.event.Status)

Aggregations

Status (io.cucumber.plugin.event.Status)6 Result (io.cucumber.plugin.event.Result)4 TimeConversion.javaDurationToDuration (io.cucumber.messages.TimeConversion.javaDurationToDuration)2 TestStepResult (io.cucumber.messages.types.TestStepResult)2 Duration (java.time.Duration)2 Instant (java.time.Instant)2 Test (org.junit.jupiter.api.Test)2 UUID (java.util.UUID)1