Beispiel #1
0
 private void runBeforeOrAfterScenarioSteps(
     RunContext context,
     Scenario scenario,
     Meta storyAndScenarioMeta,
     Stage stage,
     ScenarioType type)
     throws InterruptedException {
   runStepsWhileKeepingState(
       context, context.collectBeforeOrAfterScenarioSteps(storyAndScenarioMeta, stage, type));
 }
Beispiel #2
0
 private void runScenarioSteps(
     RunContext context, Scenario scenario, Map<String, String> scenarioParameters)
     throws InterruptedException {
   boolean restart = true;
   while (restart) {
     restart = false;
     List<Step> steps = context.collectScenarioSteps(scenario, scenarioParameters);
     try {
       runStepsWhileKeepingState(context, steps);
     } catch (RestartingScenarioFailure e) {
       restart = true;
       continue;
     }
     generatePendingStepMethods(context, steps);
   }
 }
Beispiel #3
0
 /**
  * Run steps before or after a collection of stories. Steps are execute only <b>once</b> per
  * collection of stories.
  *
  * @param configuration the Configuration used to find the steps to run
  * @param candidateSteps the List of CandidateSteps containing the candidate steps methods
  * @param stage the Stage
  * @return The State after running the steps
  */
 public State runBeforeOrAfterStories(
     Configuration configuration, List<CandidateSteps> candidateSteps, Stage stage) {
   String storyPath = capitalizeFirstLetter(stage.name().toLowerCase()) + "Stories";
   reporter.set(configuration.storyReporter(storyPath));
   reporter.get().beforeStory(new Story(storyPath), false);
   RunContext context = new RunContext(configuration, candidateSteps, storyPath, MetaFilter.EMPTY);
   if (stage == Stage.BEFORE) {
     resetStoryFailure(context);
   }
   if (stage == Stage.AFTER && storiesState.get() != null) {
     context.stateIs(storiesState.get());
   }
   try {
     runStepsWhileKeepingState(
         context,
         configuration
             .stepCollector()
             .collectBeforeOrAfterStoriesSteps(context.candidateSteps(), stage));
   } catch (InterruptedException e) {
     throw new UUIDExceptionWrapper(e);
   }
   reporter.get().afterStory(false);
   storiesState.set(context.state());
   // if we are running with multiple threads, call delayed
   // methods, otherwise we will forget to close files on BeforeStories
   if (stage == Stage.BEFORE) {
     if (reporter.get() instanceof ConcurrentStoryReporter) {
       ((ConcurrentStoryReporter) reporter.get()).invokeDelayed();
     }
   }
   // handle any after stories failure according to strategy
   if (stage == Stage.AFTER) {
     try {
       handleStoryFailureByStrategy();
     } catch (Throwable e) {
       return new SomethingHappened(storyFailure.get());
     } finally {
       if (reporter.get() instanceof ConcurrentStoryReporter) {
         ((ConcurrentStoryReporter) reporter.get()).invokeDelayed();
       }
     }
   }
   return context.state();
 }
Beispiel #4
0
 private void runLifecycleSteps(
     RunContext context, Lifecycle lifecycle, Stage stage, Meta storyAndScenarioMeta)
     throws InterruptedException {
   runStepsWhileKeepingState(
       context, context.collectLifecycleSteps(lifecycle, storyAndScenarioMeta, stage));
 }
Beispiel #5
0
 private void runBeforeOrAfterStorySteps(RunContext context, Story story, Stage stage)
     throws InterruptedException {
   runStepsWhileKeepingState(context, context.collectBeforeOrAfterStorySteps(story, stage));
 }