public RootNode run() { // TODO - why is this here twice? ExecutionContext.put(Scope.SUITE, INotificationDistributor.NOTIFIER_DISTRIBUTOR_KEY, this.notificationDistributor); this.rootNodeRunner.run(this.rootNode, this.nodeExecutionContext); if (!this.nodeExecutionContext.haveTestsBeenRun()) { final Throwable t = new IllegalStateException("No tests executed"); SubstepExecutionFailure sef = new SubstepExecutionFailure(t, this.rootNode, ExecutionResult.FAILED); //this.rootNode.getResult().setFailed(t); this.notificationDistributor.onNodeFailed(this.rootNode, t); this.nodeExecutionContext.addFailure(sef); } this.failures = this.nodeExecutionContext.getFailures(); return this.rootNode; }
private <T extends ProvidesScreenshot> byte[] getScreenshot(RootNodeExecutionContext context, Class<T> screenshotClass) { T screenshotTakingInstance = context.getMethodExecutor().getImplementation(screenshotClass); return screenshotTakingInstance.getScreenshotBytes(); }
private boolean runSetup(final NODE_TYPE node, final RootNodeExecutionContext context) { try { context.getSetupAndTeardown().runSetup(getScope(), node); return true; } catch (final Throwable t) { log.warn("setup failed", t); context.addFailure(new SubstepExecutionFailure(t, node, true)); context.getNotificationDistributor().onNodeFailed(node, t); return false; } }
public void addFailure(final SubstepExecutionFailure failure) { failures.add(failure); logFailure(failure); // set the criticality of this failure if (!failure.isSetupOrTearDown() && isNodeFailureNonCritical(failure.getExeccutionNode())) { failure.setNonCritical(true); } }
private boolean runSetup(final NODE_TYPE node, final RootNodeExecutionContext context) { try { context.getSetupAndTeardown().runSetup(getScope()); return true; } catch (final Throwable t) { log.warn("setup failed", t); context.addFailure(new SubstepExecutionFailure(t, node, true)); return false; } }
context.getNotificationDistributor().onNodeFinished(node); final List<SubstepExecutionFailure> failures = context.getFailures(); context.getNotificationDistributor().onNodeFailed(node, lastException);
@Override protected boolean execute(StepImplementationNode node, RootNodeExecutionContext context) { boolean success = false; try { context.getMethodExecutor().executeMethod(node.getTargetClass(), node.getTargetMethod(), node.getMethodArgs()); context.setTestsHaveRun(); success = true; } catch (final InvocationTargetException e) { addFailure(node, context, e.getTargetException()); } catch (final Throwable t) { addFailure(node, context, t); } return success; }
private boolean beforeExecute(final NODE_TYPE node, final RootNodeExecutionContext context) { boolean shouldContinue; if (node.hasError()) { context.getNotificationDistributor().onNodeFailed(node, node.getResult().getThrown()); context.addFailure(new SubstepExecutionFailure(node.getResult().getThrown(), node)); shouldContinue = false; } else { node.getResult().setStarted(); context.getNotificationDistributor().onNodeStarted(node); shouldContinue = runSetup(node, context); } if (!shouldContinue) { log.debug("shouldContinue = false for {}", node); } return shouldContinue; }
private void addFailure(StepImplementationNode node, RootNodeExecutionContext context, Throwable t) { byte[] screenshotBytes = attemptScreenshot(node, context); SubstepExecutionFailure failure; if (context.isNodeFailureNonCritical(node)){ failure = SubstepExecutionFailure.nonCriticalFailure(t, node, screenshotBytes); } else { failure = SubstepExecutionFailure.criticalFailure(t,node, screenshotBytes); } context.addFailure(failure); }
protected boolean addExpectedChildrenFailureIfNoChildren(final NODE_TYPE node, final List<? extends IExecutionNode> children, final RootNodeExecutionContext context) { final boolean hasChildren = children != null && !children.isEmpty(); if (!hasChildren) { context.addFailure(new SubstepExecutionFailure(new IllegalStateException( "node should have children but doesn't"), node)); } return hasChildren; }
public RootNode prepareExecutionConfig(final Config config , final Syntax syntax, final TestParameters parameters, final SetupAndTearDown setupAndTearDown , final MethodExecutor methodExecutorToUse, TagManager nonFatalTagmanager ) { final ExecutionNodeTreeBuilder nodeTreeBuilder = new ExecutionNodeTreeBuilder(parameters, config); // building the tree can throw critical failures if exceptions are found this.rootNode = nodeTreeBuilder.buildExecutionNodeTree(NewSubstepsExecutionConfig.getDescription(config)); setupExecutionListeners(NewSubstepsExecutionConfig.getExecutionListenerClasses(config)); if (NewSubstepsExecutionConfig.isCheckForUncalledAndUnused(config)) { processUncalledAndUnused(syntax, NewSubstepsExecutionConfig.getDataOutputDirectory(config)); } ExecutionContext.put(Scope.SUITE, INotificationDistributor.NOTIFIER_DISTRIBUTOR_KEY, this.notificationDistributor); this.nodeExecutionContext = new RootNodeExecutionContext(this.notificationDistributor, Lists.<SubstepExecutionFailure>newArrayList(), setupAndTearDown, nonFatalTagmanager, methodExecutorToUse); return this.rootNode; }
public void addFailure(final SubstepExecutionFailure failure) { failures.add(failure); logFailure(failure); // set the criticality of this failure if (!failure.isSetupOrTearDown() && this.nonFatalTagmanager != null && nonFatalTagmanager.isApplicable(failure.getExeccutionNode())) { failure.setNonCritical(true); } }
context.getNotificationDistributor().onNodeFinished(node); SubstepExecutionFailure.setResult(e, node, ExecutionResult.FAILED); context.getNotificationDistributor().onNodeFailed(node, e); rootNodeStateSet = true; break; SubstepExecutionFailure.setResult(e, node, ExecutionResult.NON_CRITICAL_FAILURE); context.getNotificationDistributor().onNodeFailed(node, e); rootNodeStateSet = true; context.getNotificationDistributor().onNodeFinished(node);
private void runTearDown(final NODE_TYPE node, final RootNodeExecutionContext context) { try { context.getSetupAndTeardown().runTearDown(getScope()); ExecutionContext.clear(getScope()); } catch (final SubstepsRuntimeException t) { log.warn("tear down failed", t); context.addFailure(new SubstepExecutionFailure(t, node, true)); } }
context.getNotificationDistributor().onNodeFinished(node); final List<SubstepExecutionFailure> failures = context.getFailures(); context.getNotificationDistributor().onNodeFailed(node, lastException);
context.getMethodExecutor().executeMethod(node.getTargetClass(), node.getTargetMethod(), evaluatedArgs); context.setTestsHaveRun(); success = true;
private boolean beforeExecute(final NODE_TYPE node, final RootNodeExecutionContext context) { boolean shouldContinue = true; // node.getResult().setStarted(); if (node.hasError()) { context.getNotificationDistributor().onNodeFailed(node, node.getResult().getThrown()); context.addFailure(new SubstepExecutionFailure(node.getResult().getThrown(), node)); shouldContinue = false; } else { node.getResult().setStarted(); context.getNotificationDistributor().onNodeStarted(node); shouldContinue = runSetup(node, context); } if (!shouldContinue) { log.debug("shouldContinue = false for {}", node); } return shouldContinue; }
private void addFailure(StepImplementationNode node, RootNodeExecutionContext context, Throwable t) { byte[] screenshotBytes = attemptScreenshot(node, context); context.addFailure(new SubstepExecutionFailure(t, node, screenshotBytes)); }
this.nodeExecutionContext = new RootNodeExecutionContext(this.notificationDistributor, Lists.<SubstepExecutionFailure> newArrayList(), setupAndTearDown, nonFatalTagmanager, methodExecutorToUse);
@Override public RootNode run() { // TODO - why is this here twice? ExecutionContext.put(Scope.SUITE, INotificationDistributor.NOTIFIER_DISTRIBUTOR_KEY, this.notificationDistributor); this.rootNodeRunner.run(this.rootNode, this.nodeExecutionContext); if (!this.nodeExecutionContext.haveTestsBeenRun()) { final Throwable t = new NoTestsRunException(); SubstepExecutionFailure sef = new SubstepExecutionFailure(t, this.rootNode, ExecutionResult.FAILED); this.notificationDistributor.onNodeFailed(this.rootNode, t); this.nodeExecutionContext.addFailure(sef); } this.failures = this.nodeExecutionContext.getFailures(); return this.rootNode; }