@Override public void runStep(Scenario scenario) throws Throwable { hookDefinition.execute(scenario); }
@Override public String getCodeLocation() { return hookDefinition.getLocation(false); }
private void runHookIfTagsMatch(HookDefinition hook, Reporter reporter, Set<Tag> tags, boolean isBefore) { if (hook.matches(tags)) { String status = Result.PASSED; Throwable error = null; Match match = new Match(Collections.<Argument>emptyList(), hook.getLocation(false)); stopWatch.start(); try { hook.execute(scenarioResult); } catch (Throwable t) { error = t; if (isPending(t)) { status = "pending"; } else { status = Result.FAILED; } addError(t); skipNextStep = true; } finally { long duration = stopWatch.stop(); Result result = new Result(status, duration, error, DUMMY_ARG); addHookToCounterAndResult(result); if (isBefore) { reporter.before(match, result); } else { reporter.after(match, result); } } } }
public HookDefinitionDTO(UUID glueId, long id, HookDefinition hookDefinition) { this.glueId = glueId; this.id = id; this.order = hookDefinition.getOrder(); this.location = hookDefinition.getLocation(false); this.detailedLocation = hookDefinition.getLocation(true); }
private void addTestStepsForHooks(List<HookTestStep> testSteps, List<PickleTag> tags, List<HookDefinition> hooks, HookType hookType) { for (HookDefinition hook : hooks) { if (hook.matches(tags)) { HookTestStep testStep = new HookTestStep(hookType, new HookDefinitionMatch(hook)); testSteps.add(testStep); } } }
private void removeScenarioScopedHooks(List<HookDefinition> beforeHooks) { Iterator<HookDefinition> hookIterator = beforeHooks.iterator(); while (hookIterator.hasNext()) { HookDefinition hook = hookIterator.next(); if (hook.isScenarioScoped()) { hookIterator.remove(); } } }
public boolean matches(UUID uuid, long id, Collection<TagDTO> tags) { SimpleGlue glue = glues.get(uuid); HookDefinition hookDefinition = glue.hookDefinition(id); return hookDefinition.matches(convertTags(tags)); }
public HookExecutionResult execute(UUID uuid, long id, ScenarioDTO scenarioDto) throws Throwable { SimpleGlue glue = glues.get(uuid); Scenario scenarioAdapter = new ScenarioAdapter(scenarioDto); HookDefinition hookDefinition = glue.hookDefinition(id); try { hookDefinition.execute(scenarioAdapter); } catch (Exception e) { return new HookExecutionResult(scenarioDto, e); } return new HookExecutionResult(scenarioDto); }