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