Search in sources :

Example 21 with TestCaseFinished

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

the class TestCaseResultObserverTest method skippedByDryRun.

@Test
void skippedByDryRun() {
    bus.send(new TestCaseStarted(Instant.now(), testCase));
    bus.send(new TestStepStarted(Instant.now(), testCase, testStep));
    Result result = new Result(Status.SKIPPED, Duration.ZERO, null);
    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(), instanceOf(TestAbortedException.class));
}
Also used : TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) TestAbortedException(org.opentest4j.TestAbortedException) 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 22 with TestCaseFinished

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

the class TestCaseResultObserverTest method skippedByUser.

@Test
void skippedByUser() {
    bus.send(new TestCaseStarted(Instant.now(), testCase));
    bus.send(new TestStepStarted(Instant.now(), testCase, testStep));
    Result result = new Result(Status.SKIPPED, Duration.ZERO, new TestAbortedException("thrown by user"));
    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(), instanceOf(TestAbortedException.class));
}
Also used : TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) TestAbortedException(org.opentest4j.TestAbortedException) 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 23 with TestCaseFinished

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

the class TestCase method emitTestCaseFinished.

private void emitTestCaseFinished(EventBus bus, UUID executionId, Instant stop, Duration duration, Status status, Result result) {
    bus.send(new TestCaseFinished(stop, this, result));
    TestStepResult testStepResult = new TestStepResult();
    testStepResult.setStatus(from(status));
    testStepResult.setDuration(javaDurationToDuration(duration));
    if (result.getError() != null) {
        testStepResult.setMessage(toString(result.getError()));
    }
    Envelope envelope = new Envelope();
    envelope.setTestCaseFinished(new io.cucumber.messages.types.TestCaseFinished(executionId.toString(), javaInstantToTimestamp(stop), false));
    bus.send(envelope);
}
Also used : TestStepResult(io.cucumber.messages.types.TestStepResult) TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) Envelope(io.cucumber.messages.types.Envelope)

Example 24 with TestCaseFinished

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

the class TestCaseResultObserverTest method should_not_be_passed_for_ambiguous_result.

@Test
public void should_not_be_passed_for_ambiguous_result() {
    TestCaseResultObserver resultListener = TestCaseResultObserver.observe(bus);
    Result stepResult = new Result(AMBIGUOUS, ZERO, error);
    bus.send(new TestStepFinished(now(), testCase, step, stepResult));
    Result testCaseResult = new Result(AMBIGUOUS, ZERO, error);
    bus.send(new TestCaseFinished(now(), testCase, testCaseResult));
    Exception exception = expectThrows(Exception.class, resultListener::assertTestCasePassed);
    assertEquals(exception.getCause(), error);
}
Also used : TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) SkipException(org.testng.SkipException) Result(io.cucumber.plugin.event.Result) Test(org.testng.annotations.Test)

Example 25 with TestCaseFinished

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

the class TestCaseResultObserverTest method should_be_passed_for_passed_result.

@Test
public void should_be_passed_for_passed_result() {
    TestCaseResultObserver resultListener = TestCaseResultObserver.observe(bus);
    Result stepResult = new Result(Status.PASSED, ZERO, null);
    bus.send(new TestStepFinished(now(), testCase, step, stepResult));
    Result testCaseResult = new Result(Status.PASSED, ZERO, null);
    bus.send(new TestCaseFinished(now(), testCase, testCaseResult));
    resultListener.assertTestCasePassed();
}
Also used : TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) Result(io.cucumber.plugin.event.Result) Test(org.testng.annotations.Test)

Aggregations

TestCaseFinished (io.cucumber.plugin.event.TestCaseFinished)26 Result (io.cucumber.plugin.event.Result)25 TestStepFinished (io.cucumber.plugin.event.TestStepFinished)22 Test (org.junit.jupiter.api.Test)16 TestCaseStarted (io.cucumber.plugin.event.TestCaseStarted)15 TestStepStarted (io.cucumber.plugin.event.TestStepStarted)14 Test (org.testng.annotations.Test)9 Failure (org.junit.runner.notification.Failure)7 SkipException (org.testng.SkipException)7 CucumberException (io.cucumber.core.exception.CucumberException)4 SnippetsSuggestedEvent (io.cucumber.plugin.event.SnippetsSuggestedEvent)4 Suggestion (io.cucumber.plugin.event.SnippetsSuggestedEvent.Suggestion)4 AssumptionViolatedException (org.junit.AssumptionViolatedException)4 TestAbortedException (org.opentest4j.TestAbortedException)4 MultipleFailureException (org.junit.runners.model.MultipleFailureException)3 EventBus (io.cucumber.core.eventbus.EventBus)2 UUID (java.util.UUID)2 RuntimeOptions (io.cucumber.core.options.RuntimeOptions)1 RuntimeOptionsBuilder (io.cucumber.core.options.RuntimeOptionsBuilder)1 TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)1