Search in sources :

Example 26 with Result

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

the class TestCaseResultObserverTest method passed.

@Test
void passed() {
    bus.send(new TestCaseStarted(Instant.now(), testCase));
    bus.send(new TestStepStarted(Instant.now(), testCase, testStep));
    Result result = new Result(Status.PASSED, Duration.ZERO, null);
    bus.send(new TestStepFinished(Instant.now(), testCase, testStep, result));
    bus.send(new TestCaseFinished(Instant.now(), testCase, result));
    observer.assertTestCasePassed();
}
Also used : TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) TestStepStarted(io.cucumber.plugin.event.TestStepStarted) TestCaseStarted(io.cucumber.plugin.event.TestCaseStarted) Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Example 27 with Result

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

the class TestCaseResultObserverTest method failed.

@Test
void failed() {
    bus.send(new TestCaseStarted(Instant.now(), testCase));
    bus.send(new TestStepStarted(Instant.now(), testCase, testStep));
    Throwable error = new AssertionFailedError("Mocked");
    Result result = new Result(Status.FAILED, Duration.ZERO, error);
    bus.send(new TestStepFinished(Instant.now(), testCase, testStep, result));
    bus.send(new TestCaseFinished(Instant.now(), testCase, result));
    Exception exception = assertThrows(Exception.class, observer::assertTestCasePassed);
    assertThat(exception.getCause(), is(error));
}
Also used : TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) AssertionFailedError(org.opentest4j.AssertionFailedError) TestStepStarted(io.cucumber.plugin.event.TestStepStarted) TestCaseStarted(io.cucumber.plugin.event.TestCaseStarted) TestAbortedException(org.opentest4j.TestAbortedException) Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Example 28 with Result

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

the class CucumberExecutionContext method emitTestRunFinished.

private void emitTestRunFinished(Throwable exception) {
    Instant instant = bus.getInstant();
    Result result = new Result(exception != null ? Status.FAILED : exitStatus.getStatus(), Duration.between(start, instant), exception);
    bus.send(new TestRunFinished(instant, result));
    io.cucumber.messages.types.TestRunFinished testRunFinished = new io.cucumber.messages.types.TestRunFinished(exception != null ? printStackTrace(exception) : null, exception == null && exitStatus.isSuccess(), javaInstantToTimestamp(instant));
    Envelope envelope = new Envelope();
    envelope.setTestRunFinished(testRunFinished);
    bus.send(envelope);
}
Also used : Instant(java.time.Instant) TestRunFinished(io.cucumber.plugin.event.TestRunFinished) Envelope(io.cucumber.messages.types.Envelope) Result(io.cucumber.plugin.event.Result)

Example 29 with Result

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

the class PrettyFormatter method printError.

private void printError(TestRunFinished event) {
    Result result = event.getResult();
    printError(result);
}
Also used : Result(io.cucumber.plugin.event.Result)

Example 30 with Result

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

the class PrettyFormatter method printError.

private void printError(TestStepFinished event) {
    Result result = event.getResult();
    printError(result);
}
Also used : Result(io.cucumber.plugin.event.Result)

Aggregations

Result (io.cucumber.plugin.event.Result)56 Test (org.junit.jupiter.api.Test)41 TestStepFinished (io.cucumber.plugin.event.TestStepFinished)29 TestCaseFinished (io.cucumber.plugin.event.TestCaseFinished)26 TestCaseStarted (io.cucumber.plugin.event.TestCaseStarted)15 TestStepStarted (io.cucumber.plugin.event.TestStepStarted)14 Test (org.testng.annotations.Test)9 UUID (java.util.UUID)7 Failure (org.junit.runner.notification.Failure)7 SkipException (org.testng.SkipException)7 PickleStepTestStep (io.cucumber.plugin.event.PickleStepTestStep)6 Status (io.cucumber.plugin.event.Status)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 List (java.util.List)6 TestAbortedException (org.opentest4j.TestAbortedException)6 EventBus (io.cucumber.core.eventbus.EventBus)5 SnippetsSuggestedEvent (io.cucumber.plugin.event.SnippetsSuggestedEvent)5 Suggestion (io.cucumber.plugin.event.SnippetsSuggestedEvent.Suggestion)5 TestRunFinished (io.cucumber.plugin.event.TestRunFinished)5 OutputStream (java.io.OutputStream)5