Search in sources :

Example 6 with TestCaseFinished

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

the class TestCaseResultObserverTest method should_not_be_passed_for_failed_result.

@Test
public void should_not_be_passed_for_failed_result() {
    TestCaseResultObserver resultListener = TestCaseResultObserver.observe(bus);
    Result stepResult = new Result(FAILED, ZERO, error);
    bus.send(new TestStepFinished(now(), testCase, step, stepResult));
    Result testCaseResult = new Result(FAILED, 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 7 with TestCaseFinished

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

the class TestCaseResultObserverTest method should_be_failed_for_undefined_result.

@Test
public void should_be_failed_for_undefined_result() {
    TestCaseResultObserver resultListener = TestCaseResultObserver.observe(bus);
    bus.send(new SnippetsSuggestedEvent(now(), uri, location, location, new Suggestion("some step", singletonList("stub snippet"))));
    Result stepResult = new Result(UNDEFINED, ZERO, error);
    bus.send(new TestStepFinished(now(), testCase, step, stepResult));
    Result testCaseResult = new Result(UNDEFINED, ZERO, error);
    bus.send(new TestCaseFinished(now(), testCase, testCaseResult));
    Exception exception = expectThrows(Exception.class, resultListener::assertTestCasePassed);
    assertThat(exception.getCause(), instanceOf(SkipException.class));
    SkipException skipException = (SkipException) exception.getCause();
    assertThat(skipException.isSkip(), is(false));
    assertThat(skipException.getMessage(), is("" + "The step 'some step' is undefined.\n" + "You can implement this step using the snippet(s) below:\n" + "\n" + "stub snippet\n"));
}
Also used : Suggestion(io.cucumber.plugin.event.SnippetsSuggestedEvent.Suggestion) TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) SnippetsSuggestedEvent(io.cucumber.plugin.event.SnippetsSuggestedEvent) SkipException(org.testng.SkipException) SkipException(org.testng.SkipException) Result(io.cucumber.plugin.event.Result) Test(org.testng.annotations.Test)

Example 8 with TestCaseFinished

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

the class TestCaseResultObserverTest method should_not_be_skipped_for_undefined_result.

@Test
public void should_not_be_skipped_for_undefined_result() {
    TestCaseResultObserver resultListener = TestCaseResultObserver.observe(bus);
    bus.send(new SnippetsSuggestedEvent(now(), uri, location, location, new SnippetsSuggestedEvent.Suggestion("some step", singletonList("stub snippet"))));
    Result stepResult = new Result(UNDEFINED, ZERO, error);
    bus.send(new TestStepFinished(now(), testCase, step, stepResult));
    Result testCaseResult = new Result(UNDEFINED, ZERO, error);
    bus.send(new TestCaseFinished(now(), testCase, testCaseResult));
    Exception exception = expectThrows(Exception.class, resultListener::assertTestCasePassed);
    assertThat(exception.getCause(), instanceOf(SkipException.class));
    SkipException skipException = (SkipException) exception.getCause();
    assertThat(skipException.isSkip(), is(false));
    assertThat(skipException.getMessage(), is("" + "The step 'some step' is undefined.\n" + "You can implement this step using the snippet(s) below:\n" + "\n" + "stub snippet\n"));
}
Also used : Suggestion(io.cucumber.plugin.event.SnippetsSuggestedEvent.Suggestion) TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) SnippetsSuggestedEvent(io.cucumber.plugin.event.SnippetsSuggestedEvent) SkipException(org.testng.SkipException) SkipException(org.testng.SkipException) Result(io.cucumber.plugin.event.Result) Test(org.testng.annotations.Test)

Example 9 with TestCaseFinished

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

the class TestCaseResultObserverTest method should_be_passed_for_empty_scenario.

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

Example 10 with TestCaseFinished

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

the class TestCaseResultObserverTest method undefined.

@Test
void undefined() {
    bus.send(new TestCaseStarted(Instant.now(), testCase));
    bus.send(new TestStepStarted(Instant.now(), testCase, testStep));
    bus.send(new SnippetsSuggestedEvent(Instant.now(), uri, testCase.getLocation(), testStep.getStep().getLocation(), new Suggestion(testStep.getStep().getText(), asList("mocked snippet 1", "mocked snippet 2", "mocked snippet 3"))));
    Result result = new Result(Status.UNDEFINED, 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(UndefinedStepException.class));
    assertThat(exception.getCause().getMessage(), is("" + "The step 'mocked' is undefined.\n" + "You can implement this step using the snippet(s) below:\n" + "\n" + "mocked snippet 1\n" + "mocked snippet 2\n" + "mocked snippet 3\n"));
}
Also used : Suggestion(io.cucumber.plugin.event.SnippetsSuggestedEvent.Suggestion) TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) SnippetsSuggestedEvent(io.cucumber.plugin.event.SnippetsSuggestedEvent) 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)

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