public String getName() { return gherkinDocument.getFeature().getName(); }
@Override public String map(Tag tag) { return tag.getName(); } };
ExamplesRowWrapperNode(Node examplesRow, int bodyRowIndex) { super(examplesRow.getLocation()); this.bodyRowIndex = bodyRowIndex; } }
private void processScenarioOutlineExamples(Map<Integer, AstNode> nodeMap, ScenarioOutline scenarioOutline, AstNode childNode) { for (Examples examples : scenarioOutline.getExamples()) { AstNode examplesNode = new AstNode(examples, childNode); TableRow headerRow = examples.getTableHeader(); AstNode headerNode = new AstNode(headerRow, examplesNode); nodeMap.put(headerRow.getLocation().getLine(), headerNode); for (int i = 0; i < examples.getTableBody().size(); ++i) { TableRow examplesRow = examples.getTableBody().get(i); Node rowNode = new ExamplesRowWrapperNode(examplesRow, i); AstNode expandedScenarioNode = new AstNode(rowNode, examplesNode); nodeMap.put(examplesRow.getLocation().getLine(), expandedScenarioNode); } } }
private void printScenarioOutline(ScenarioOutline scenarioOutline) { out.println(); printTags(scenarioOutline.getTags(), SCENARIO_INDENT); out.println(SCENARIO_INDENT + getScenarioDefinitionText(scenarioOutline) + " " + getLocationText(currentFeatureFile, scenarioOutline.getLocation().getLine())); printDescription(scenarioOutline.getDescription()); for (Step step : scenarioOutline.getSteps()) { out.println(STEP_INDENT + formats.get("skipped").text(step.getKeyword() + step.getText())); } }
@Override public String getName() { Feature feature = cucumberFeature.getGherkinFeature().getFeature(); return feature.getKeyword() + ": " + feature.getName(); }
private void processScenarioDefinition(Map<Integer, AstNode> nodeMap, ScenarioDefinition child, AstNode currentParent) { AstNode childNode = new AstNode(child, currentParent); nodeMap.put(child.getLocation().getLine(), childNode); for (Step step : child.getSteps()) { nodeMap.put(step.getLocation().getLine(), new AstNode(step, childNode)); } if (child instanceof ScenarioOutline) { processScenarioOutlineExamples(nodeMap, (ScenarioOutline) child, childNode); } }
private void addOutlineStepsToReport(ScenarioOutline scenarioOutline) { for (Step step : scenarioOutline.getSteps()) { Map<String, Object> stepMap = new HashMap<String, Object>(); stepMap.put("name", step.getText()); stepMap.put("keyword", step.getKeyword()); if (step.getArgument() != null) { Node argument = step.getArgument(); if (argument instanceof DocString) { stepMap.put("doc_string", createDocStringMap((DocString)argument)); } else if (argument instanceof DataTable) { stepMap.put("rows", createDataTableList((DataTable)argument)); } } jsFunctionCall("step", stepMap); } }
private StepNode processScenarioDefinition(Map<Integer, StepNode> stepMap, StepNode initialPreviousNode, ScenarioDefinition child) { StepNode previousNode = initialPreviousNode; for (Step step : child.getSteps()) { StepNode stepNode = new StepNode(step, previousNode); stepMap.put(step.getLocation().getLine(), stepNode); previousNode = stepNode; } return previousNode; }
private void printExamples(Examples examples) { out.println(); printTags(examples.getTags(), EXAMPLES_INDENT); out.println(EXAMPLES_INDENT + examples.getKeyword() + ": " + examples.getName()); printDescription(examples.getDescription()); }
static String calculateId(AstNode astNode) { Node node = astNode.node; if (node instanceof ScenarioDefinition) { return calculateId(astNode.parent) + ";" + convertToId(((ScenarioDefinition) node).getName()); } if (node instanceof ExamplesRowWrapperNode) { return calculateId(astNode.parent) + ";" + Integer.toString(((ExamplesRowWrapperNode) node).bodyRowIndex + 2); } if (node instanceof TableRow) { return calculateId(astNode.parent) + ";" + Integer.toString(1); } if (node instanceof Examples) { return calculateId(astNode.parent) + ";" + convertToId(((Examples) node).getName()); } if (node instanceof Feature) { return convertToId(((Feature) node).getName()); } return ""; }
Feature getFeature(String path) { if (!pathToAstMap.containsKey(path)) { parseGherkinSource(path); } if (pathToAstMap.containsKey(path)) { return pathToAstMap.get(path).getFeature(); } return null; }
static Background getBackgroundForTestCase(AstNode astNode) { Feature feature = getFeatureForTestCase(astNode); ScenarioDefinition backgound = feature.getChildren().get(0); if (backgound instanceof Background) { return (Background) backgound; } else { return null; } }
private void printBackground(TestCase testCase) { TestSourcesModel.AstNode astNode = testSources.getAstNode(currentFeatureFile, testCase.getLine()); if (astNode != null) { Background background = TestSourcesModel.getBackgroundForTestCase(astNode); String backgroundText = getScenarioDefinitionText(background); boolean useBackgroundSteps = true; calculateLocationIndentation(SCENARIO_INDENT + backgroundText, testCase.getTestSteps(), useBackgroundSteps); String locationPadding = createPaddingToLocation(SCENARIO_INDENT, backgroundText); out.println(); out.println(SCENARIO_INDENT + backgroundText + locationPadding + getLocationText(currentFeatureFile, background.getLocation().getLine())); printDescription(background.getDescription()); } }
private String getScenarioDefinitionText(ScenarioDefinition definition) { return definition.getKeyword() + ": " + definition.getName(); }
String getFeatureName(String uri) { Feature feature = getFeature(uri); if (feature != null) { return feature.getName(); } return ""; }
private String getStepKeyword(PickleStepTestStep testStep) { TestSourcesModel.AstNode astNode = testSources.getAstNode(currentFeatureFile, testStep.getStepLine()); if (astNode != null) { Step step = (Step) astNode.node; return step.getKeyword(); } else { return ""; } }
private Map<String, Object> createDocStringMap(DocString docString) { Map<String, Object> docStringMap = new HashMap<String, Object>(); docStringMap.put("value", docString.getContent()); return docStringMap; }
@Override public String toString() { return "\"" + cucumberFeature.getGherkinFeature().getFeature().getName() + "\""; } }