Search in sources :

Example 6 with TestCaseStarted

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

the class TestCaseResultObserverTest method empty.

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

Example 7 with TestCaseStarted

use of io.cucumber.plugin.event.TestCaseStarted 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 8 with TestCaseStarted

use of io.cucumber.plugin.event.TestCaseStarted 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 9 with TestCaseStarted

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

the class ThreadLocalRunnerSupplierTest method should_limit_runner_bus_scope_to_events_generated_by_runner.

@Test
void should_limit_runner_bus_scope_to_events_generated_by_runner() {
    // This avoids problems with JUnit which listens to individual runners
    runnerSupplier.get().getBus().registerHandlerFor(TestCaseStarted.class, event -> fail("Should not receive event"));
    eventBus.send(new TestCaseStarted(EPOCH, mock(TestCase.class)));
}
Also used : TestCaseStarted(io.cucumber.plugin.event.TestCaseStarted) Test(org.junit.jupiter.api.Test)

Example 10 with TestCaseStarted

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

the class JUnitReporterWithStepNotificationsTest method ignores_steps_when_step_notification_are_disabled.

@Test
void ignores_steps_when_step_notification_are_disabled() {
    EventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
    JUnitReporter jUnitReporter = new JUnitReporter(bus, new JUnitOptionsBuilder().setStepNotifications(false).build());
    jUnitReporter.startExecutionUnit(pickleRunner, runNotifier);
    bus.send(new TestCaseStarted(now(), testCase));
    bus.send(new TestStepStarted(now(), testCase, mockTestStep(step)));
    Result result = new Result(Status.PASSED, ZERO, null);
    bus.send(new TestStepFinished(now(), testCase, mockTestStep(step), result));
    bus.send(new TestCaseFinished(now(), testCase, result));
    verify(runNotifier, never()).fireTestStarted(pickleRunner.describeChild(step));
    verify(runNotifier, never()).fireTestFinished(pickleRunner.describeChild(step));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) EventBus(io.cucumber.core.eventbus.EventBus) UUID(java.util.UUID) TestStepStarted(io.cucumber.plugin.event.TestStepStarted) TestCaseStarted(io.cucumber.plugin.event.TestCaseStarted) Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Aggregations

TestCaseStarted (io.cucumber.plugin.event.TestCaseStarted)21 Test (org.junit.jupiter.api.Test)18 Result (io.cucumber.plugin.event.Result)16 TestCaseFinished (io.cucumber.plugin.event.TestCaseFinished)16 TestStepStarted (io.cucumber.plugin.event.TestStepStarted)16 TestStepFinished (io.cucumber.plugin.event.TestStepFinished)15 Failure (org.junit.runner.notification.Failure)7 CucumberException (io.cucumber.core.exception.CucumberException)4 AssumptionViolatedException (org.junit.AssumptionViolatedException)4 TestAbortedException (org.opentest4j.TestAbortedException)4 SnippetsSuggestedEvent (io.cucumber.plugin.event.SnippetsSuggestedEvent)3 Suggestion (io.cucumber.plugin.event.SnippetsSuggestedEvent.Suggestion)3 MultipleFailureException (org.junit.runners.model.MultipleFailureException)3 Location (io.cucumber.plugin.event.Location)2 TestCase (io.cucumber.plugin.event.TestCase)2 EventBus (io.cucumber.core.eventbus.EventBus)1 ExceptionUtils.printStackTrace (io.cucumber.core.exception.ExceptionUtils.printStackTrace)1 TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)1 Envelope (io.cucumber.messages.types.Envelope)1 EventListener (io.cucumber.plugin.EventListener)1