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);
}
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"));
}
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"));
}
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();
}
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"));
}
Aggregations