use of io.cucumber.plugin.event.TestCaseEvent in project cucumber-jvm by cucumber.
the class PickleStepTestStepTest method step_execution_time_is_measured.
@Test
void step_execution_time_is_measured() {
Feature feature = TestFeatureParser.parse("" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given I have 4 cukes in my belly\n");
TestStep step = new PickleStepTestStep(UUID.randomUUID(), URI.create("file:path/to.feature"), feature.getPickles().get(0).getSteps().get(0), definitionMatch);
when(bus.getInstant()).thenReturn(ofEpochMilli(234L), ofEpochMilli(1234L));
step.run(testCase, bus, state, ExecutionMode.RUN);
ArgumentCaptor<TestCaseEvent> captor = forClass(TestCaseEvent.class);
verify(bus, times(4)).send(captor.capture());
List<TestCaseEvent> allValues = captor.getAllValues();
TestStepStarted started = (TestStepStarted) allValues.get(0);
TestStepFinished finished = (TestStepFinished) allValues.get(2);
assertAll(() -> assertThat(started.getInstant(), is(equalTo(ofEpochMilli(234L)))), () -> assertThat(finished.getInstant(), is(equalTo(ofEpochMilli(1234L)))), () -> assertThat(finished.getResult().getDuration(), is(equalTo(ofMillis(1000L)))));
}
use of io.cucumber.plugin.event.TestCaseEvent 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)));
}
use of io.cucumber.plugin.event.TestCaseEvent in project cucumber-jvm by cucumber.
the class PickleStepTestStepTest method result_is_result_from_hook_when_before_step_hook_does_not_pass.
@Test
void result_is_result_from_hook_when_before_step_hook_does_not_pass() {
Exception exception = new RuntimeException();
doThrow(exception).when(beforeHookDefinition).execute(any(TestCaseState.class));
Result failure = new Result(Status.FAILED, ZERO, exception);
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(2)).getResult(), is(equalTo(failure)));
}
Aggregations