Skip to content

Commit

Permalink
update PrettyFormatter to print table
Browse files Browse the repository at this point in the history
  • Loading branch information
artysidorenko committed Aug 4, 2021
1 parent 1be1b52 commit 6b34d6a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions core/src/main/java/io/cucumber/core/plugin/PrettyFormatter.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package io.cucumber.core.plugin;

import io.cucumber.core.exception.CucumberException;
import io.cucumber.core.gherkin.DataTableArgument;
import io.cucumber.datatable.DataTable;
import io.cucumber.datatable.DataTableFormatter;
import io.cucumber.plugin.ColorAware;
import io.cucumber.plugin.ConcurrentEventListener;
import io.cucumber.plugin.event.Argument;
import io.cucumber.plugin.event.EmbedEvent;
import io.cucumber.plugin.event.EventPublisher;
import io.cucumber.plugin.event.PickleStepTestStep;
import io.cucumber.plugin.event.Result;
import io.cucumber.plugin.event.StepArgument;
import io.cucumber.plugin.event.TestCase;
import io.cucumber.plugin.event.TestCaseStarted;
import io.cucumber.plugin.event.TestRunFinished;
Expand Down Expand Up @@ -128,6 +132,21 @@ private void printStep(TestStepFinished event) {
formats.get(status + "_arg"), testStep.getDefinitionArgument());
String locationIndent = calculateLocationIndent(event.getTestCase(), formatPlainStep(keyword, stepText));
out.println(STEP_INDENT + formattedStepText + locationIndent + formatLocation(testStep.getCodeLocation()));

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);
}
}
}
}

Expand Down

0 comments on commit 6b34d6a

Please sign in to comment.