Search in sources :

Example 1 with DataTableFormatter

use of io.cucumber.datatable.DataTableFormatter 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)

Aggregations

CucumberException (io.cucumber.core.exception.CucumberException)1 DataTableArgument (io.cucumber.core.gherkin.DataTableArgument)1 DataTableFormatter (io.cucumber.datatable.DataTableFormatter)1 PickleStepTestStep (io.cucumber.plugin.event.PickleStepTestStep)1 StepArgument (io.cucumber.plugin.event.StepArgument)1 IOException (java.io.IOException)1