use of io.cucumber.plugin.event.PickleStepTestStep in project syndesis-qe by syndesisio.
the class PrettyFormatter method printStep.
private void printStep(TestStepStarted event) {
if (event.getTestStep() instanceof PickleStepTestStep) {
PickleStepTestStep testStep = (PickleStepTestStep) event.getTestStep();
String keyword = testStep.getStep().getKeyword();
String stepText = testStep.getStep().getText();
String formattedStepText = formatStepText(keyword, stepText, formats.get("executing"), formats.get("executing_arg"), testStep.getDefinitionArgument());
String locationIndent = calculateLocationIndent(event.getTestCase(), formatPlainStep(keyword, stepText));
out.println(STEP_INDENT + formattedStepText + locationIndent + formatLocation(testStep.getCodeLocation()));
}
}
use of io.cucumber.plugin.event.PickleStepTestStep in project cucumber-jvm by cucumber.
the class EventBusTest method handlers_receive_the_events_they_registered_for.
@Test
void handlers_receive_the_events_they_registered_for() {
EventHandler<TestStepFinished> handler = mock(EventHandler.class);
PickleStepTestStep testStep = mock(PickleStepTestStep.class);
Result result = new Result(Status.PASSED, ZERO, null);
TestCase testCase = mock(TestCase.class);
TestStepFinished event = new TestStepFinished(EPOCH, testCase, testStep, result);
EventBus bus = new TimeServiceEventBus(Clock.fixed(Instant.EPOCH, ZoneId.of("UTC")), UUID::randomUUID);
bus.registerHandlerFor(TestStepFinished.class, handler);
bus.send(event);
verify(handler).receive(event);
}
use of io.cucumber.plugin.event.PickleStepTestStep in project cucumber-jvm by cucumber.
the class JUnitReporterWithStepNotificationsTest method mockTestStep.
private static PickleStepTestStep mockTestStep(Step step) {
PickleStepTestStep testStep = mock(PickleStepTestStep.class);
lenient().when(testStep.getUri()).thenReturn(featureUri);
lenient().when(testStep.getStep()).thenReturn(step);
return testStep;
}
use of io.cucumber.plugin.event.PickleStepTestStep in project cucumber-jvm by cucumber.
the class JUnitReporter method handTestStepStarted.
private void handTestStepStarted(TestStepStarted event) {
TestStep testStep = event.getTestStep();
if (testStep instanceof PickleStepTestStep) {
PickleStepTestStep pickleStep = (PickleStepTestStep) testStep;
if (junitOptions.stepNotifications()) {
Description description = pickleRunner.describeChild(pickleStep.getStep());
stepNotifier = new EachTestNotifier(runNotifier, description);
} else {
stepNotifier = new NoTestNotifier();
}
stepNotifier.fireTestStarted();
}
}
use of io.cucumber.plugin.event.PickleStepTestStep in project cucumber-jvm by cucumber.
the class JsonFormatter method handleTestStepStarted.
@SuppressWarnings("unchecked")
private void handleTestStepStarted(TestStepStarted event) {
if (event.getTestStep() instanceof PickleStepTestStep) {
PickleStepTestStep testStep = (PickleStepTestStep) event.getTestStep();
if (isFirstStepAfterBackground(testStep)) {
currentElementMap = currentTestCaseMap;
currentStepsList = (List<Map<String, Object>>) currentElementMap.get("steps");
}
currentStepOrHookMap = createTestStep(testStep);
// add beforeSteps list to current step
if (currentBeforeStepHookList.containsKey(before)) {
currentStepOrHookMap.put(before, currentBeforeStepHookList.get(before));
currentBeforeStepHookList.clear();
}
currentStepsList.add(currentStepOrHookMap);
} else if (event.getTestStep() instanceof HookTestStep) {
HookTestStep hookTestStep = (HookTestStep) event.getTestStep();
currentStepOrHookMap = createHookStep(hookTestStep);
addHookStepToTestCaseMap(currentStepOrHookMap, hookTestStep.getHookType());
} else {
throw new IllegalStateException();
}
}
Aggregations