public boolean inOneOf(StepEndState... states) { boolean result = false; for ( StepEndState s : states) { if ( s == getEndState()) { result = true; break; } } return result; }
/** * The end state of a step macro step is derived from the child steps * If all child steps are PASSED then the step macro will be PASSED, * otherwise the step macro end state is taken from the first child step which was not PASSED */ public static StepEndState calculateStepMacroEndState(List<StepToken> executedSteps) { StepEndState stepMacroEndState = StepEndState.PASSED; for ( StepToken s : executedSteps) { if ( s.getEndState() != StepEndState.PASSED) { stepMacroEndState = s.getEndState(); break; } } return stepMacroEndState; }
/** * 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; }
/** * May be overridden (e.g. to add control codes for colouring terminal output) */ protected String getEndState(StepToken step) { return step.getEndState().toString(); }
public EndState getEndState() { EndState result = EndState.PASSED; for ( StepToken s : steps) { //steps may all be skipped if a feature start scenario failed - the subsequent scenario should all fail if ( s.inOneOf(FAILED, UNDEFINED, TIMEOUT, NOT_RUN, SKIPPED) ) { result = EndState.FAILED; break; } else if ( s.getEndState() == StepEndState.PENDING ) { result = EndState.PENDING; break; } } return result; }
/** * @return End state as a String containing terminal control codes to colourize output, unless disableColours sys prop is set true */ protected String getEndState(StepToken step) { StepEndState endState = step.getEndState(); return disableColours ? endState.toString() : colourizeEndState(endState); }
@Override public StepTokenBean marshal(StepToken v) throws Exception { StepTokenBean toRet = new StepTokenBean(); toRet.setTokenId(v.getTokenId()); toRet.setType(v.getType()); toRet.setAction(v.getAction()); toRet.setEndState(v.getEndState()); toRet.setMessage(v.getMessage()); //we don't want to add an error details attribute unless there's a real value if ( ! "".equals(v.getErrorDetails().trim())) { toRet.setErrorDetails(v.getErrorDetails()); } if (v.getException()!=null){ toRet.setException(v.getException()); toRet.setStackTrace(v.getStackTrace()); } toRet.setTimeTaken(v.getTimeTaken()); toRet.setTimeTakenSeconds(FormattingUtils.getTimeTakenAsSecondsString(v.getTimeTaken())); toRet.setChildSteps(v.getChildSteps()); return toRet; }