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