private ScenarioToken createScenario(String name, ScenarioToken backgroundScenario, List<String> currentFeaturesTags, List<String> currentScenariosTags) { ScenarioToken scenario = new ScenarioToken(); //add any background steps first if (backgroundScenario != null) { for (StepToken backgroundStep : backgroundScenario.getSteps()) { //pass empty list of macros since background steps have already been matched to step macros and expanded, //we add a deep copy of the background step, which will also contain copies of any macro child steps. StepToken copiedStep = backgroundStep.deepCopy(); addStepToScenario(scenario, copiedStep, Collections.<StepMacro>emptyList()); } } scenario.setName(name); //add the filter tags scenario.addTags(currentFeaturesTags); scenario.addTags(currentScenariosTags); return scenario; }
private ScenarioToken createScenarioFromOutline(String scenarioName, ScenarioToken outlineScenario, List<String> placeholders, List<String> values,List<String> currentFeaturesTags, List<String> currentScenariosTags, List<StepMacro> stepMacros) { ScenarioToken scenario = new ScenarioToken(); List<String> outlineVariableTags = findChorusTagsFromOutlineVariables(placeholders, values); //append the first paramter to the scenario name if there is one String firstParam = " " + (!values.isEmpty() ? values.get(0) : ""); scenarioName += firstParam.trim().length() > 0 ? firstParam : ""; scenario.setName(scenarioName); //then the outline scenario steps for (StepToken step : outlineScenario.getSteps()) { String action = step.getAction(); for (int i = 0; i < placeholders.size(); i++) { String placeholder = placeholders.get(i); String value = values.get(i); value = RegexpUtils.escapeRegexReplacement(value); action = action.replaceAll("<" + placeholder + ">", value); } addStepToScenario(scenario, createStepToken(step.getType(), action), stepMacros); } //add the filter tags scenario.addTags(currentFeaturesTags); scenario.addTags(currentScenariosTags); scenario.addTags(outlineVariableTags); return scenario; }