use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.
the class PickleStepTestStepTest method result_is_result_from_hook_when_after_step_hook_does_not_pass.
@Test
void result_is_result_from_hook_when_after_step_hook_does_not_pass() {
Exception exception = new RuntimeException();
Result failure = new Result(Status.FAILED, ZERO, exception);
doThrow(exception).when(afterHookDefinition).execute(any(TestCaseState.class));
ExecutionMode nextExecutionMode = step.run(testCase, bus, state, ExecutionMode.RUN);
assertThat(nextExecutionMode, is(ExecutionMode.SKIP));
assertThat(state.getStatus(), is(equalTo(FAILED)));
ArgumentCaptor<Object> captor = forClass(TestCaseEvent.class);
verify(bus, times(12)).send(captor.capture());
List<Object> allValues = captor.getAllValues();
assertThat(((TestStepFinished) allValues.get(10)).getResult(), is(equalTo(failure)));
}
use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.
the class PluginFactoryTest method plugin_does_not_buffer_its_output.
@Test
void plugin_does_not_buffer_its_output() {
PrintStream previousSystemOut = System.out;
OutputStream mockSystemOut = new ByteArrayOutputStream();
try {
System.setOut(new PrintStream(mockSystemOut));
// Need to create a new plugin factory here since we need it to pick
// up the new value of System.out
fc = new PluginFactory();
PluginOption option = parse("progress");
ProgressFormatter plugin = (ProgressFormatter) fc.create(option);
EventBus bus = new TimeServiceEventBus(new ClockStub(ZERO), UUID::randomUUID);
plugin.setEventPublisher(bus);
Result result = new Result(Status.PASSED, ZERO, null);
TestStepFinished event = new TestStepFinished(bus.getInstant(), mock(TestCase.class), mock(PickleStepTestStep.class), result);
bus.send(event);
assertThat(mockSystemOut.toString(), is(not(equalTo(""))));
} finally {
System.setOut(previousSystemOut);
}
}
use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.
the class TestCaseStateResultTest method passed_and_skipped_is_skipped_although_we_cant_have_skipped_without_undefined_or_pending.
@Test
void passed_and_skipped_is_skipped_although_we_cant_have_skipped_without_undefined_or_pending() {
s.add(new Result(Status.PASSED, ZERO, null));
s.add(new Result(Status.SKIPPED, ZERO, null));
assertAll(() -> assertThat(s.getStatus(), is(equalTo(SKIPPED))), () -> assertFalse(s.isFailed()));
}
use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.
the class TestCaseStateResultTest method passed_undefined_skipped_is_undefined.
@Test
void passed_undefined_skipped_is_undefined() {
s.add(new Result(Status.PASSED, ZERO, null));
s.add(new Result(Status.UNDEFINED, ZERO, null));
s.add(new Result(Status.SKIPPED, ZERO, null));
assertAll(() -> assertThat(s.getStatus(), is(equalTo(UNDEFINED))), () -> assertFalse(s.isFailed()));
}
use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.
the class CucumberExecutionContextTest method emits_failures_in_events.
@Test
public void emits_failures_in_events() {
List<TestRunStarted> testRunStarted = new ArrayList<>();
List<TestRunFinished> testRunFinished = new ArrayList<>();
bus.registerHandlerFor(TestRunStarted.class, testRunStarted::add);
bus.registerHandlerFor(TestRunFinished.class, testRunFinished::add);
context.startTestRun();
assertThrows(IllegalStateException.class, () -> context.runTestCase(runner -> {
throw failure;
}));
context.finishTestRun();
assertThat(testRunStarted.get(0), notNullValue());
Result result = testRunFinished.get(0).getResult();
assertThat(result.getStatus(), is(Status.FAILED));
assertThat(result.getError(), is(failure));
}
Aggregations