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