use of io.cucumber.core.gherkin.DataTableArgument 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);
}
}
}
}
use of io.cucumber.core.gherkin.DataTableArgument in project cucumber-jvm by cucumber.
the class ArgumentMatcher method argumentsFrom.
public List<Argument> argumentsFrom(Step step, Type... types) {
io.cucumber.core.gherkin.Argument arg = step.getArgument();
if (arg == null) {
return expression.match(step.getText(), types);
}
if (arg instanceof io.cucumber.core.gherkin.DocStringArgument) {
DocStringArgument docString = (DocStringArgument) arg;
String content = docString.getContent();
String contentType = docString.getMediaType();
return expression.match(step.getText(), content, contentType, types);
}
if (arg instanceof io.cucumber.core.gherkin.DataTableArgument) {
DataTableArgument table = (DataTableArgument) arg;
List<List<String>> cells = emptyCellsToNull(table.cells());
return expression.match(step.getText(), cells, types);
}
throw new IllegalStateException("Argument was neither PickleString nor PickleTable");
}
use of io.cucumber.core.gherkin.DataTableArgument in project cucumber-jvm by cucumber.
the class FeatureParserTest method empty_table_is_parsed.
@Test
void empty_table_is_parsed() throws IOException {
URI uri = URI.create("classpath:com/example.feature");
String source = new String(readAllBytes(Paths.get("src/test/resources/io/cucumber/core/gherkin/messages/empty-table.feature")));
Feature feature = parser.parse(uri, source, UUID::randomUUID).get();
Pickle pickle = feature.getPickles().get(0);
Step step = pickle.getSteps().get(0);
DataTableArgument argument = (DataTableArgument) step.getArgument();
assertEquals(5, argument.getLine());
}
Aggregations