use of io.cucumber.plugin.event.PickleStepTestStep in project cucumber-jvm by cucumber.
the class EventBusTest method handlers_do_not_receive_the_events_they_did_not_registered_for.
@Test
void handlers_do_not_receive_the_events_they_did_not_registered_for() {
EventHandler handler = mock(EventHandler.class);
PickleStepTestStep testStep = mock(PickleStepTestStep.class);
TestCase testCase = mock(TestCase.class);
TestStepStarted event = new TestStepStarted(EPOCH, testCase, testStep);
EventBus bus = new TimeServiceEventBus(Clock.fixed(Instant.EPOCH, ZoneId.of("UTC")), UUID::randomUUID);
bus.registerHandlerFor(TestStepFinished.class, handler);
bus.send(event);
verify(handler, never()).receive(event);
}
use of io.cucumber.plugin.event.PickleStepTestStep in project cucumber-jvm by cucumber.
the class UsageFormatterTest method resultWithNullDuration.
// Note: Duplicate of above test
@Test
void resultWithNullDuration() {
OutputStream out = new ByteArrayOutputStream();
UsageFormatter usageFormatter = new UsageFormatter(out);
PickleStepTestStep testStep = mockTestStep();
Result result = new Result(Status.PASSED, Duration.ZERO, null);
usageFormatter.handleTestStepFinished(new TestStepFinished(Instant.EPOCH, mock(TestCase.class), testStep, result));
Map<String, List<UsageFormatter.StepContainer>> usageMap = usageFormatter.usageMap;
assertThat(usageMap.size(), is(equalTo(1)));
List<UsageFormatter.StepContainer> durationEntries = usageMap.get("stepDef");
assertThat(durationEntries.size(), is(equalTo(1)));
assertThat(durationEntries.get(0).getName(), is(equalTo("step")));
assertThat(durationEntries.get(0).getDurations().size(), is(equalTo(1)));
assertThat(durationEntries.get(0).getDurations().get(0).getDuration(), is(equalTo(0.0)));
}
use of io.cucumber.plugin.event.PickleStepTestStep in project cucumber-jvm by cucumber.
the class UsageFormatterTest method mockTestStep.
private PickleStepTestStep mockTestStep() {
PickleStepTestStep testStep = mock(PickleStepTestStep.class, Mockito.RETURNS_MOCKS);
when(testStep.getPattern()).thenReturn("stepDef");
when(testStep.getStepText()).thenReturn("step");
return testStep;
}
use of io.cucumber.plugin.event.PickleStepTestStep in project cucumber-jvm by cucumber.
the class JUnitReporter method handleTestStepFinished.
private void handleTestStepFinished(TestStepFinished event) {
if (event.getTestStep() instanceof PickleStepTestStep) {
PickleStepTestStep testStep = (PickleStepTestStep) event.getTestStep();
handleStepResult(testStep, event.getResult());
} else {
handleHookResult(event.getResult());
}
}
use of io.cucumber.plugin.event.PickleStepTestStep in project cucumber-jvm by cucumber.
the class TeamCityPlugin method extractName.
private String extractName(TestStep step) {
if (step instanceof PickleStepTestStep) {
PickleStepTestStep pickleStepTestStep = (PickleStepTestStep) step;
return pickleStepTestStep.getStep().getText();
}
if (step instanceof HookTestStep) {
HookTestStep hook = (HookTestStep) step;
HookType hookType = hook.getHookType();
switch(hookType) {
case BEFORE:
return "Before";
case AFTER:
return "After";
case BEFORE_STEP:
return "BeforeStep";
case AFTER_STEP:
return "AfterStep";
default:
return hookType.name().toLowerCase(Locale.US);
}
}
return "Unknown step";
}
Aggregations