use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.
the class ResultTest method is_query_returns_true_for_the_status_of_the_result_object.
@Test
void is_query_returns_true_for_the_status_of_the_result_object() {
int checkCount = 0;
for (Status status : Status.values()) {
Result result = new Result(status, ZERO, null);
assertTrue(result.getStatus().is(result.getStatus()));
checkCount += 1;
}
assertThat("No checks performed", checkCount > 0, is(equalTo(true)));
}
use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.
the class ResultTest method failed_result_is_not_ok.
@Test
void failed_result_is_not_ok() {
Result failedResult = new Result(FAILED, ZERO, null);
assertFalse(failedResult.getStatus().isOk());
}
use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.
the class ResultTest method severity_from_low_to_high_is_passed_skipped_pending_undefined_ambiguous_failed.
@Test
void severity_from_low_to_high_is_passed_skipped_pending_undefined_ambiguous_failed() {
Result passed = new Result(PASSED, ZERO, null);
Result skipped = new Result(SKIPPED, ZERO, null);
Result pending = new Result(PENDING, ZERO, null);
Result ambiguous = new Result(AMBIGUOUS, ZERO, null);
Result undefined = new Result(UNDEFINED, ZERO, null);
Result failed = new Result(FAILED, ZERO, null);
List<Result> results = asList(pending, passed, skipped, failed, ambiguous, undefined);
results.sort(Comparator.comparing(Result::getStatus));
assertThat(results, equalTo(asList(passed, skipped, pending, undefined, ambiguous, failed)));
}
use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.
the class UnusedStepsSummaryPrinterTest method verifyUnusedStepsPrinted.
@Test
void verifyUnusedStepsPrinted() {
ByteArrayOutputStream out = new ByteArrayOutputStream();
UnusedStepsSummaryPrinter summaryPrinter = new UnusedStepsSummaryPrinter(out);
summaryPrinter.setMonochrome(true);
TimeServiceEventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
summaryPrinter.setEventPublisher(bus);
// Register two steps, use one, then finish the test run
bus.send(new StepDefinedEvent(bus.getInstant(), mockStepDef("my/belly.feature:3", "a few cukes")));
bus.send(new StepDefinedEvent(bus.getInstant(), mockStepDef("my/tummy.feature:5", "some more cukes")));
bus.send(new StepDefinedEvent(bus.getInstant(), mockStepDef("my/gut.feature:7", "even more cukes")));
bus.send(new TestStepFinished(bus.getInstant(), mock(TestCase.class), mockTestStep("my/belly.feature:3"), new Result(Status.UNUSED, Duration.ZERO, null)));
bus.send(new StepDefinedEvent(bus.getInstant(), mockStepDef("my/belly.feature:3", "a few cukes")));
bus.send(new StepDefinedEvent(bus.getInstant(), mockStepDef("my/tummy.feature:5", "some more cukes")));
bus.send(new StepDefinedEvent(bus.getInstant(), mockStepDef("my/gut.feature:7", "even more cukes")));
bus.send(new TestStepFinished(bus.getInstant(), mock(TestCase.class), mockTestStep("my/gut.feature:7"), new Result(Status.UNUSED, Duration.ZERO, null)));
bus.send(new TestRunFinished(bus.getInstant(), new Result(Status.PASSED, Duration.ZERO, null)));
// Verify produced output
assertThat(out, isBytesEqualTo("1 Unused steps:\n" + "my/tummy.feature:5 # some more cukes\n"));
}
use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.
the class PickleStepTestStepTest method result_is_result_from_step_when_step_hook_does_not_pass.
@Test
void result_is_result_from_step_when_step_hook_does_not_pass() throws Throwable {
RuntimeException runtimeException = new RuntimeException();
Result failure = new Result(Status.FAILED, ZERO, runtimeException);
doThrow(runtimeException).when(definitionMatch).runStep(any(TestCaseState.class));
ExecutionMode nextExecutionMode = step.run(testCase, bus, state, ExecutionMode.RUN);
assertThat(nextExecutionMode, is(ExecutionMode.SKIP));
assertThat(state.getStatus(), is(equalTo(FAILED)));
ArgumentCaptor<TestCaseEvent> captor = forClass(TestCaseEvent.class);
verify(bus, times(12)).send(captor.capture());
List<TestCaseEvent> allValues = captor.getAllValues();
assertThat(((TestStepFinished) allValues.get(6)).getResult(), is(equalTo(failure)));
}
Aggregations