commit 1719269f6d66144864d2437c94f4516e11a39249
Author:     Mauro Talevi <mauro.tal...@aquilonia.org>
AuthorDate: Fri, 2 May 2014 14:06:03 +0200
Commit:     Mauro Talevi <mauro.tal...@aquilonia.org>
CommitDate: Fri, 2 May 2014 14:06:03 +0200

    JBEHAVE-777:  Perform given stories before scenarios.

diff --git 
a/jbehave-core/src/main/java/org/jbehave/core/embedder/PerformableTree.java 
b/jbehave-core/src/main/java/org/jbehave/core/embedder/PerformableTree.java
index b78d7d3..0e7ccf2 100644
--- a/jbehave-core/src/main/java/org/jbehave/core/embedder/PerformableTree.java
+++ b/jbehave-core/src/main/java/org/jbehave/core/embedder/PerformableTree.java
@@ -715,6 +715,7 @@ public class PerformableTree {
             State state = context.state();
             Timer timer = new Timer().start();
             try {
+               performGivenStories(context);
                 performScenarios(context);
             } finally {
                 timing.setDurationInMillis(timer.stop());
@@ -723,6 +724,16 @@ public class PerformableTree {
             this.status = context.status(state);
         }
 
+               private void performGivenStories(RunContext context) throws 
InterruptedException {
+                       if (givenStories.size() > 0) {
+                               
context.reporter().givenStories(story.getGivenStories());
+                               for (PerformableStory story : givenStories) {
+                                       context.givenStory = story.givenStory();
+                                       story.perform(context);
+                               }
+                       }
+               }
+               
         private void performScenarios(RunContext context) throws 
InterruptedException {
             beforeSteps.perform(context);
             for (PerformableScenario scenario : scenarios) {
@@ -852,7 +863,7 @@ public class PerformableTree {
                 context.resetState();
             }
             beforeSteps.perform(context);
-            if (scenario.getGivenStories().getPaths().size() > 0) {
+                       if (givenStories.size() > 0) {
                                
context.reporter().givenStories(scenario.getGivenStories());
                                for (PerformableStory story : givenStories) {
                                        context.givenStory = story.givenStory();
@@ -881,6 +892,7 @@ public class PerformableTree {
             context.reporter().example(parameters);
             beforeSteps.perform(context);
             for (PerformableStory story : givenStories) {
+                               context.givenStory = story.givenStory();
                 story.perform(context);
             }
             steps.perform(context);



Reply via email to