/** * If a Feature-Start: section fails or a handler for a feature is not found, all steps may be skipped * * @return true if this scenario Failed because it was skipped (all child steps are skipped) */ public boolean wasSkipped() { return getSteps().stream().filter(s -> s.getEndState() != StepEndState.SKIPPED).count() == 0; }
/** * Creates a pretty formatted Feature */ @Override public String toString() { final StringBuilder sb = new StringBuilder(); if ( usesHandlers != null) { for (String s : usesHandlers) { sb.append("Using: ").append(s).append("\n"); } if (usesHandlers.length > 0) { sb.append("\n"); } } sb.append("Feature: ").append(name).append('\n'); String descriptionStr = " " + description.toString().trim().replaceAll("\n", "\n "); sb.append(descriptionStr).append('\n'); for (ScenarioToken scenario : scenarios) { sb.append('\n').append(" ").append(scenario.toString()).append('\n'); List<StepToken> steps = scenario.getSteps(); for (StepToken step : steps) { sb.append(" ").append(step.toString()).append('\n'); } } return sb.toString(); } }
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 ScenarioTokenBean marshal(ScenarioToken s) throws Exception { ScenarioTokenBean result = new ScenarioTokenBean(); result.setTokenId(s.getTokenId()); result.setName(s.getName()); result.setSteps(s.getSteps()); List<String> tags = s.getTags(); result.setTags(tags.size() == 0 ? null : FormattingUtils.getAsCsv(s.getTags())); result.setEndState(s.getEndState()); return result; }
private void runScenario(ExecutionToken executionToken, HandlerManager handlerManager, ScenarioToken scenario, boolean skipScenario) throws Exception { executionListenerSupport.notifyScenarioStarted(executionToken, scenario); log.info(String.format("Processing scenario: %s", scenario.getName())); //reset the ChorusContext for the scenario ChorusContext.destroy(); handlerManager.setCurrentScenario(scenario); List<Object> handlerInstances = Collections.emptyList(); if ( ! skipScenario) { handlerInstances = handlerManager.getOrCreateHandlersForScenario(); } handlerManager.processStartOfScope(Scope.SCENARIO, handlerInstances); StepInvokerProvider p = getStepInvokers(handlerInstances); createTimeoutTasks(Thread.currentThread()); //will interrupt or eventually kill thread / interpreter if blocked log.debug((skipScenario ? "Skipping" : "Running") + " scenario steps for Scenario " + scenario); stepProcessor.runSteps(executionToken, p, scenario.getSteps(), stepCatalogue, skipScenario); stopTimeoutTasks(); //the special start or end scenarios don't count in the execution stats if ( ! scenario.isStartOrEndScenario() ) { updateExecutionStats(executionToken, scenario); } handlerManager.processEndOfScope(Scope.SCENARIO, handlerInstances); executionListenerSupport.notifyScenarioCompleted(executionToken, scenario); }