Search in sources :

Example 6 with PickleStepTestStep

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

the class JsonFormatter method createMatchMap.

private Map<String, Object> createMatchMap(TestStep step, Result result) {
    Map<String, Object> matchMap = new HashMap<>();
    if (step instanceof PickleStepTestStep) {
        PickleStepTestStep testStep = (PickleStepTestStep) step;
        if (!testStep.getDefinitionArgument().isEmpty()) {
            List<Map<String, Object>> argumentList = new ArrayList<>();
            for (Argument argument : testStep.getDefinitionArgument()) {
                Map<String, Object> argumentMap = new HashMap<>();
                if (argument.getValue() != null) {
                    argumentMap.put("val", argument.getValue());
                    argumentMap.put("offset", argument.getStart());
                }
                argumentList.add(argumentMap);
            }
            matchMap.put("arguments", argumentList);
        }
    }
    if (!result.getStatus().is(Status.UNDEFINED)) {
        matchMap.put("location", step.getCodeLocation());
    }
    return matchMap;
}
Also used : PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) DocStringArgument(io.cucumber.plugin.event.DocStringArgument) StepArgument(io.cucumber.plugin.event.StepArgument) Argument(io.cucumber.plugin.event.Argument) DataTableArgument(io.cucumber.plugin.event.DataTableArgument) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 7 with PickleStepTestStep

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

the class PrettyFormatter method preCalculateLocationIndent.

private void preCalculateLocationIndent(TestCaseStarted event) {
    TestCase testCase = event.getTestCase();
    Integer longestStep = testCase.getTestSteps().stream().filter(PickleStepTestStep.class::isInstance).map(PickleStepTestStep.class::cast).map(PickleStepTestStep::getStep).map(step -> formatPlainStep(step.getKeyword(), step.getText()).length()).max(Comparator.naturalOrder()).orElse(0);
    int scenarioLength = formatScenarioDefinition(testCase).length();
    commentStartIndex.put(testCase.getId(), max(longestStep, scenarioLength) + 1);
}
Also used : PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) TestCase(io.cucumber.plugin.event.TestCase)

Example 8 with PickleStepTestStep

use of io.cucumber.plugin.event.PickleStepTestStep in project syndesis-qe by syndesisio.

the class PrettyFormatter method preCalculateLocationIndent.

private void preCalculateLocationIndent(TestCaseStarted event) {
    TestCase testCase = event.getTestCase();
    Integer longestStep = testCase.getTestSteps().stream().filter(PickleStepTestStep.class::isInstance).map(PickleStepTestStep.class::cast).map(PickleStepTestStep::getStep).map(step -> formatPlainStep(step.getKeyword(), step.getText()).length()).max(Comparator.naturalOrder()).orElse(0);
    int scenarioLength = formatScenarioDefinition(testCase).length();
    commentStartIndex.put(testCase.getId(), max(longestStep, scenarioLength) + 1);
}
Also used : PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) TestCase(io.cucumber.plugin.event.TestCase)

Example 9 with PickleStepTestStep

use of io.cucumber.plugin.event.PickleStepTestStep in project syndesis-qe by syndesisio.

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 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 10 with PickleStepTestStep

use of io.cucumber.plugin.event.PickleStepTestStep in project syndesis-qe by syndesisio.

the class ReportPortalFormatter method onTestStepStarted.

/**
 * Print a step name to the log before each step starts
 */
private void onTestStepStarted(TestStepStarted t) {
    if ((!scenarioAlreadyFailed) && t.getTestStep() instanceof PickleStepTestStep) {
        PickleStepTestStep testStep = (PickleStepTestStep) t.getTestStep();
        testCaseLog.append("STEP: ").append(testStep.getStep().getKeyword()).append(testStep.getStep().getText()).append("\n");
    }
}
Also used : PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep)

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