private StepEndState handleInterruptedException(ExecutionToken executionToken, StepToken step, Throwable cause) { StepEndState endState; if ( interruptingOnTimeout ) { log.warn("Interrupted during step processing, will TIMEOUT remaining steps"); interruptingOnTimeout = false; endState = StepEndState.TIMEOUT; } else { log.warn("Interrupted during step processing but this was not due to TIMEOUT, will fail step"); endState = StepEndState.FAILED; } executionToken.incrementStepsFailed(); step.setMessage("Interrupted"); step.setErrorDetails(getErrorDetails(cause)); Thread.currentThread().isInterrupted(); //clear the interrupted status return endState; }
private StepEndState handleGenericException(ExecutionToken executionToken, StepToken step, Throwable cause) { StepEndState endState; step.setThrowable(cause); String causeMessage = cause.getMessage(); causeMessage = causeMessage == null ? "" : causeMessage; log.debug("Step failed due to exception " + cause); String errorDetails = getErrorDetails(cause); step.setMessage(causeMessage); step.setErrorDetails(errorDetails); endState = StepEndState.FAILED; executionToken.incrementStepsFailed(); return endState; }
private StepEndState handleStepPendingException(ExecutionToken executionToken, StepToken step, StepPendingException cause) { StepEndState endState; step.setThrowable(cause); step.setMessage(cause.getMessage()); endState = StepEndState.PENDING; executionToken.incrementStepsPending(); log.debug("Step Pending Exception prevented execution"); return endState; } }
private StepEndState callStepMethod(ExecutionToken executionToken, StepToken step, StepEndState endState, StepMatcher stepMatcher, StepCatalogue stepCatalogue) { //setting a pending message in the step annotation implies the step is pending - we don't execute it StepInvoker chosenStepInvoker = stepMatcher.getFoundStepInvoker(); if ( chosenStepInvoker.isPending()) { String pendingMessage = chosenStepInvoker.getPendingMessage(); log.debug("Step has a pending message " + pendingMessage + " skipping step"); step.setMessage(pendingMessage); endState = StepEndState.PENDING; executionToken.incrementStepsPending(); } else { if (dryRun) { log.debug("Dry Run, so not executing this step"); step.setMessage("This step is OK"); endState = StepEndState.DRYRUN; executionToken.incrementStepsPassed(); // treat dry run as passed? This state was unsupported in previous results } else { endState = executeStepMethod(executionToken, step, stepMatcher, stepCatalogue); } } return endState; }
step.setMessage(result.toString());
@Override public StepToken unmarshal(StepTokenBean v) throws Exception { StepToken stepToken = StepToken.createStep(v.getType(), v.getAction()); stepToken.setEndState(v.getEndState()); stepToken.setMessage(v.getMessage()); stepToken.setException(v.getException()); stepToken.setStackTrace(v.getStackTrace()); stepToken.setTimeTaken(v.getTimeTaken()); if ( v.getErrorDetails() != null ) { stepToken.setErrorDetails(v.getErrorDetails()); } for ( StepToken c : v.getChildSteps()) { stepToken.addChildStep(c); } return stepToken; }
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); }