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; }
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; }
@Override public ScenarioToken unmarshal(ScenarioTokenBean v) throws Exception { ScenarioToken scenarioToken = new ScenarioToken(); scenarioToken.setName(v.getName()); scenarioToken.setSteps(v.getSteps()); String tags = v.getTags(); if ( tags != null ) { scenarioToken.setTags(FormattingUtils.getStringListFromCsv(tags)); } return scenarioToken; }
private void createFeatureFour() { ScenarioToken scenarioFour = new ScenarioToken(); scenarioFour.setName("Scenario Four"); StepToken step = scenarioFour.addStep(StepToken.createStep("If", "I add a step to scenario 3")); step.setEndState(StepEndState.SKIPPED); FeatureToken featureFour = new FeatureToken(); featureFour.setName("Feature Four Failed No Handler"); featureFour.addScenario(scenarioFour); listOfFeatures.add(featureFour); }
private void createFeatureThree() { ScenarioToken scenarioThree = new ScenarioToken(); scenarioThree.setName("Scenario Three"); StepToken stepSix = scenarioThree.addStep(StepToken.createStep("If", "I add a step to scenario 3")); stepSix.setEndState(StepEndState.TIMEOUT); StepToken stepSeven = scenarioThree.addStep(StepToken.createStep("If", "I add another skipped step to scenario 3")); stepSeven.setEndState(StepEndState.SKIPPED); FeatureToken featureThree = new FeatureToken(); featureThree.setName("Feature Three"); featureThree.addScenario(scenarioThree); listOfFeatures.add(featureThree); }
private void createFeatureTwo() { ScenarioToken scenarioTwo = new ScenarioToken(); scenarioTwo.setName("Scenario Two"); StepToken stepFour = scenarioTwo.addStep(StepToken.createStep("If", "I add a step to scenario 2")); stepFour.setEndState(StepEndState.UNDEFINED); StepToken stepFive = scenarioTwo.addStep(StepToken.createStep("If", "I add another skipped step to scenario 2")); stepFive.setEndState(StepEndState.SKIPPED); FeatureToken featureTwo = new FeatureToken(); featureTwo.setName("Feature Two"); featureTwo.addScenario(scenarioTwo); listOfFeatures.add(featureTwo); }
@Before public void doBefore() { scenarioToken = new ScenarioToken(); scenarioToken.setName("Test Scenario"); stepOne = scenarioToken.addStep(StepToken.createStep("If", "I create a step")); stepTwo = scenarioToken.addStep(StepToken.createStep("If", "I create a second step")); stepThree = StepToken.createStep("If", "I create a step macro child step"); stepTwo.addChildStep(stepThree); scenarioTwo = new ScenarioToken(); stepFour = scenarioTwo.addStep(StepToken.createStep("If", "I add a step to scenario 2")); featureToken = new FeatureToken(); featureToken.addScenario(scenarioToken); featureToken.addScenario(scenarioTwo); featureTwo = new FeatureToken(); executionToken = new ExecutionToken("My test suite name"); testSuite = new TestSuite(executionToken, Arrays.asList(featureToken, featureTwo)); }
private void createFeatureOne() { ScenarioToken scenarioToken = new ScenarioToken(); scenarioToken.setName("Test Scenario"); StepToken stepOne = scenarioToken.addStep(StepToken.createStep("If", "I create a step")); stepOne.setEndState(StepEndState.PASSED); StepToken stepTwo = scenarioToken.addStep(StepToken.createStep("If", "I create a second step")); stepTwo.setEndState(StepEndState.FAILED); StepToken stepChild = StepToken.createStep("If", "I create a step macro child step"); stepChild.setEndState(StepEndState.FAILED); stepTwo.addChildStep(stepChild); StepToken stepGrandchild = StepToken.createStep("If", "I create a step grandchild"); stepGrandchild.setEndState(StepEndState.FAILED); stepGrandchild.setMessage("Failed due to a horrific and unforseen cataclysm"); stepChild.addChildStep(stepGrandchild); StepToken peerStep = StepToken.createStep("If", "I create a peer step which was skipped"); peerStep.setEndState(StepEndState.SKIPPED); stepChild.addChildStep(peerStep); FeatureToken featureToken = new FeatureToken(); featureToken.setName("Feature One"); featureToken.addScenario(scenarioToken); listOfFeatures.add(featureToken); }