public boolean runBackgroundIfPresent(BasicScenarioNode node, RootNodeExecutionContext context) { return node.getBackground() == null || backgroundRunner.run(node.getBackground(), context); }
public List<StepNode> getSteps() { return getChildren(); }
@Override protected boolean execute(BasicScenarioNode node, RootNodeExecutionContext context) { log.info("Executing scenario {}", node.getDescription()); this.context = context; boolean success = runBackgroundIfPresent(node, context); Iterator<StepNode> stepIt = node.getSteps().iterator(); while (success && stepIt.hasNext()) { StepNode step = stepIt.next(); success &= step.dispatch(this); } return success; }
log.debug("Failed to parse " + scenario.getDescription() + ", creating dummy node", t); scenarioNode = new BasicScenarioNode(scenario.getDescription(), null, Collections.<StepNode> emptyList(), Collections.<String> emptySet(), depth);
@Override public Void visit(BasicScenarioNode scenarioNode) { Set<TestCounterSet> testStats = getAllStatsForTags(scenarioNode.getTags()); for (StepNode childNode : scenarioNode.getChildren()) { for (TestCounterSet stats : testStats) { stats.getScenarioStepStats().apply(childNode); } } return null; }
@Override public String getDescription() { return rowIndex + " " + getChildren().get(0).getScenarioName() + ":"; }
@Override public <RETURN_TYPE> List<RETURN_TYPE> accept(ExecutionNodeVisitor<RETURN_TYPE> executionNodeVisitor) { List<RETURN_TYPE> toReturn = Lists.newArrayList(); toReturn.add(executionNodeVisitor.visit(this)); if (getChildren().size() == 1) { toReturn.addAll(getChildren().get(0).accept(executionNodeVisitor)); } return toReturn; }
private ScenarioNode<? extends IExecutionNode> buildRunnableScenarioNode(final Scenario scenario, Set<String> inheritedTags, int depth) { ScenarioNode<?> scenarioNode = null; try { if (scenario.isOutline()) { scenarioNode = buildOutlineScenarioNode(scenario, inheritedTags, depth); } else { scenarioNode = buildBasicScenarioNode(scenario, null, inheritedTags, depth); } } catch (final Exception e) { // something has gone wrong parsing this scenario, no point // running it so mark it as failed now if (log.isDebugEnabled()) { log.debug("Failed to parse " + scenario.getDescription() + ", creating dummy node", e); } scenarioNode = new BasicScenarioNode(scenario.getDescription(), null, Collections.<StepNode>emptyList(), Collections.<String>emptySet(), depth); // ctor has side effects... eeeurgh! new SubstepExecutionFailure(e, scenarioNode, ExecutionResult.PARSE_FAILURE); if (parameters.isFailParseErrorsImmediately()) { throw new SubstepsConfigurationException(e); } } return scenarioNode; }
@Override protected boolean execute(BasicScenarioNode node, RootNodeExecutionContext context) { log.info("Executing scenario {}", node.getDescription()); this.context = context; boolean success = runBackgroundIfPresent(node, context); Iterator<StepNode> stepIt = node.getSteps().iterator(); while (success && stepIt.hasNext()) { StepNode step = stepIt.next(); success &= step.dispatch(this); } return success; }
public BasicScenarioNode buildBasicScenarioNode(final Scenario scenario, final ExampleParameter scenarioParameters, Set<String> inheritedTags, int depth) { Set<String> allTags = Sets.newHashSet(); allTags.addAll(inheritedTags); if (scenario.getTags() != null) { allTags.addAll(scenario.getTags()); } SubstepNode background = scenario.hasBackground() ? substepNodeBuilder.build(scenario.getDescription(), scenario.getBackground().getSteps(), parameters.getSyntax().getSubStepsMap(), null, scenarioParameters, true, allTags, depth + 1) : null; List<StepNode> steps = Lists.newArrayList(); if (scenario.hasSteps()) { for (Step step : scenario.getSteps()) { steps.add(substepNodeBuilder.buildStepNode(scenario.getDescription(), step, parameters.getSyntax() .getSubStepsMap(), null, scenarioParameters, false, allTags, depth + 1)); } } return new BasicScenarioNode(scenario.getDescription(), background, steps, allTags, depth); }
@Override public <RETURN_TYPE> List<RETURN_TYPE> accept(final ExecutionNodeVisitor<RETURN_TYPE> executionNodeVisitor) { final List<RETURN_TYPE> results = Lists.newArrayList(); results.add(executionNodeVisitor.visit(this)); if (this.background != null) { results.addAll(this.background.accept(executionNodeVisitor)); } for (final StepNode step : getChildren()) { results.addAll(step.accept(executionNodeVisitor)); } return results; }
public boolean runBackgroundIfPresent(BasicScenarioNode node, RootNodeExecutionContext context) { return node.getBackground() == null || backgroundRunner.run(node.getBackground(), context); }
public BasicScenarioNode buildBasicScenarioNode(final Scenario scenario, final ExampleParameter scenarioParameters, Set<String> inheritedTags, int depth) { Set<String> allTags = Sets.newHashSet(); allTags.addAll(inheritedTags); if (scenario.getTags() != null) { allTags.addAll(scenario.getTags()); } SubstepNode background = scenario.hasBackground() ? substepNodeBuilder.build(scenario.getDescription(), scenario.getBackground().getSteps(), parameters.getSyntax().getSubStepsMap(), null, scenarioParameters, true, allTags, depth + 1) : null; List<StepNode> steps = Lists.newArrayList(); if (scenario.hasSteps()) { for (Step step : scenario.getSteps()) { steps.add(substepNodeBuilder.buildStepNode(scenario.getDescription(), step, parameters.getSyntax().getSubStepsMap(), null, scenarioParameters, false, allTags, depth + 1)); } } String scenarioDescription = scenarioParameters == null ? scenario.getDescription() : SubstepNodeBuilder.substitutePlaceholders(scenario.getDescription(), scenarioParameters.getParameters()); return new BasicScenarioNode(scenarioDescription, background, steps, allTags, depth); }