/** * May be overridden (e.g. to add control codes for colouring terminal output) */ protected String getStepText(StepToken step) { return step.toString(); }
/** * 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 boolean doProcessStep(StepToken stepToken, List<StepMacro> macros, int depth, boolean alreadyMatched) { boolean result = false; if ( depth > MAX_STEP_DEPTH ) { throw new RecursiveStepMacroException("Maximum Step Depth (" + MAX_STEP_DEPTH + ") was reached when processing step " + stepToken.toString() + " are your StepMacro: infinitely recursive?"); } Matcher macroMatcher = pattern.matcher(stepToken.getAction()); if ( macroMatcher.matches() ) { if (! alreadyMatched) { //sometimes we are just matching, looking for duplicate matches log.debug(stepToken.getAction() + " matches StepMacro: " + pattern + ", will add " + steps.size() + " child steps"); addChildSteps(stepToken, macroMatcher, macros, depth); } else { log.debug(stepToken.getAction() + " matches StepMacro: " + pattern); log.warn("Duplicate StepMacro: match for step " + stepToken.getAction() + pattern + ", Chorus will use the steps from the first match"); } result = true; } return result; }