Search in sources :

Example 16 with PickleStepTestStep

use of io.cucumber.plugin.event.PickleStepTestStep in project cucumber-jvm by cucumber.

the class JsonFormatter method createTestStep.

private Map<String, Object> createTestStep(PickleStepTestStep testStep) {
    Map<String, Object> stepMap = new HashMap<>();
    stepMap.put("name", testStep.getStepText());
    stepMap.put("line", testStep.getStepLine());
    TestSourcesModel.AstNode astNode = testSources.getAstNode(currentFeatureFile, testStep.getStepLine());
    StepArgument argument = testStep.getStepArgument();
    if (argument != null) {
        if (argument instanceof DocStringArgument) {
            DocStringArgument docStringArgument = (DocStringArgument) argument;
            stepMap.put("doc_string", createDocStringMap(docStringArgument));
        } else if (argument instanceof DataTableArgument) {
            DataTableArgument dataTableArgument = (DataTableArgument) argument;
            stepMap.put("rows", createDataTableList(dataTableArgument));
        }
    }
    if (astNode != null) {
        Step step = (Step) astNode.node;
        stepMap.put("keyword", step.getKeyword());
    }
    return stepMap;
}
Also used : StepArgument(io.cucumber.plugin.event.StepArgument) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) DataTableArgument(io.cucumber.plugin.event.DataTableArgument) TestStep(io.cucumber.plugin.event.TestStep) PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) HookTestStep(io.cucumber.plugin.event.HookTestStep) Step(io.cucumber.messages.types.Step) DocStringArgument(io.cucumber.plugin.event.DocStringArgument)

Example 17 with PickleStepTestStep

use of io.cucumber.plugin.event.PickleStepTestStep in project cucumber-jvm by cucumber.

the class PrettyFormatter method printStep.

private void printStep(TestStepFinished event) {
    if (event.getTestStep() instanceof PickleStepTestStep) {
        PickleStepTestStep testStep = (PickleStepTestStep) event.getTestStep();
        String keyword = testStep.getStep().getKeyword();
        String stepText = testStep.getStep().getText();
        String status = event.getResult().getStatus().name().toLowerCase(ROOT);
        String formattedStepText = formatStepText(keyword, stepText, formats.get(status), formats.get(status + "_arg"), testStep.getDefinitionArgument());
        String locationComment = formatLocationComment(event, testStep, keyword, stepText);
        out.println(STEP_INDENT + formattedStepText + locationComment);
        StepArgument stepArgument = testStep.getStep().getArgument();
        if (DataTableArgument.class.isInstance(stepArgument)) {
            DataTableFormatter tableFormatter = DataTableFormatter.builder().prefixRow(STEP_SCENARIO_INDENT).escapeDelimiters(false).build();
            DataTableArgument dataTableArgument = (DataTableArgument) stepArgument;
            try {
                tableFormatter.formatTo(DataTable.create(dataTableArgument.cells()), out);
            } catch (IOException e) {
                throw new CucumberException(e);
            }
        }
    }
}
Also used : DataTableFormatter(io.cucumber.datatable.DataTableFormatter) PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) StepArgument(io.cucumber.plugin.event.StepArgument) DataTableArgument(io.cucumber.core.gherkin.DataTableArgument) IOException(java.io.IOException) CucumberException(io.cucumber.core.exception.CucumberException)

Example 18 with PickleStepTestStep

use of io.cucumber.plugin.event.PickleStepTestStep in project cucumber-jvm by cucumber.

the class UsageFormatter method handleTestStepFinished.

void handleTestStepFinished(TestStepFinished event) {
    if (event.getTestStep() instanceof PickleStepTestStep && event.getResult().getStatus().is(Status.PASSED)) {
        PickleStepTestStep testStep = (PickleStepTestStep) event.getTestStep();
        addUsageEntry(event.getResult(), testStep);
    }
}
Also used : PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep)

Example 19 with PickleStepTestStep

use of io.cucumber.plugin.event.PickleStepTestStep in project cucumber-jvm by cucumber.

the class TestCaseResultObserverTest method createPickleStepTestStep.

private PickleStepTestStep createPickleStepTestStep() {
    PickleStepTestStep testStep = mock(PickleStepTestStep.class);
    Step step = mock(Step.class);
    when(step.getLocation()).thenReturn(location);
    when(testStep.getStep()).thenReturn(step);
    when(testStep.getUri()).thenReturn(uri);
    return testStep;
}
Also used : PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) Step(io.cucumber.plugin.event.Step)

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