Search in sources :

Example 11 with PickleStepTestStep

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()));
    }
}
Also used : PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep)

Example 12 with PickleStepTestStep

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);
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) TestCase(io.cucumber.plugin.event.TestCase) TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) EventBus(io.cucumber.core.eventbus.EventBus) UUID(java.util.UUID) Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Example 13 with PickleStepTestStep

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;
}
Also used : PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep)

Example 14 with PickleStepTestStep

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();
    }
}
Also used : TestStep(io.cucumber.plugin.event.TestStep) PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) Description(org.junit.runner.Description)

Example 15 with PickleStepTestStep

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();
    }
}
Also used : PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) HookTestStep(io.cucumber.plugin.event.HookTestStep) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

PickleStepTestStep (io.cucumber.plugin.event.PickleStepTestStep)19 TestCase (io.cucumber.plugin.event.TestCase)4 HookTestStep (io.cucumber.plugin.event.HookTestStep)3 StepArgument (io.cucumber.plugin.event.StepArgument)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 Test (org.junit.jupiter.api.Test)3 EventBus (io.cucumber.core.eventbus.EventBus)2 TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)2 DataTableArgument (io.cucumber.plugin.event.DataTableArgument)2 DocStringArgument (io.cucumber.plugin.event.DocStringArgument)2 Result (io.cucumber.plugin.event.Result)2 TestStep (io.cucumber.plugin.event.TestStep)2 TestStepFinished (io.cucumber.plugin.event.TestStepFinished)2 Map (java.util.Map)2 UUID (java.util.UUID)2 CucumberException (io.cucumber.core.exception.CucumberException)1 DataTableArgument (io.cucumber.core.gherkin.DataTableArgument)1 DataTableFormatter (io.cucumber.datatable.DataTableFormatter)1 Step (io.cucumber.messages.types.Step)1