Jorge Pombar | 8 May 2012 04:59
Favicon

Using GivenStories can I turn off execution of GivenStories ran using a Meta tag?

I have all the stories of my project in a single folder “src/main/stories”

I’m building my test cases/stories in small blocks. So I test Story1 and then I test Story2 but it depends on Story1 to have been completed. So I’m using GivenStories:

-          Story1.story

-          Story2.story (uses GivenStories: Story1.story)

-          Story3.story (uses GivenStories: Story2.story)

 

I’m wondering if there is a way to add a meta tag on Story1 and Story2 that tells the framework not to run them because they will be run as part of Story3.story

 

Thanks for your help,

Enrique

 

Mauro Talevi | 8 May 2012 12:07

Re: Using GivenStories can I turn off execution of GivenStories ran using a Meta tag?

Hi,

no, this behaviour is not currently available.  GivenStories are recursively run.  

What you could do is set meta properties at a scenario level which are passed to the given stories and then in your implementation take notice of these properties to run or not the relevant steps.

Otherwise, structure your given dependency tree in such a way as to avoid duplication. 

Feel free to suggest a way to configure this behaviour you're after. 

Cheers

On 08/05/2012 04:59, Jorge Pombar wrote:

I have all the stories of my project in a single folder “src/main/stories”

I’m building my test cases/stories in small blocks. So I test Story1 and then I test Story2 but it depends on Story1 to have been completed. So I’m using GivenStories:

-          Story1.story

-          Story2.story (uses GivenStories: Story1.story)

-          Story3.story (uses GivenStories: Story2.story)

 

I’m wondering if there is a way to add a meta tag on Story1 and Story2 that tells the framework not to run them because they will be run as part of Story3.story

 

Thanks for your help,

Enrique

 


Jorge Pombar | 9 May 2012 02:21
Favicon

RE: Using GivenStories can I turn off execution of GivenStories ran using a Meta tag?

Currently I’m half way there. On the storyPaths() method instead of using the out of the box find paths:

return new StoryFinder().findPaths(codeLocationFromClass(this.getClass()).getFile(), asList("**/" + System.getProperty("storyFilter", "*") + ".story"), null);

 

I have a separate file that lists all the story files:

Story1.story

#Story2.story

Story3.story

 

Then I have a small parser that parses this file skipping any lines commented out (my choice was #) and returns me the List I can feed into findPaths method. My return statement now looks like

return new StoryFinder().findPaths(codeLocationFromClass(this.getClass()).getFile(), myStoryList, null);

where myStoryList was the list I populated with my parser

 

So now I don’t run Story2.story (in this case) by itself. However, all the cases inside Story2.story still run when I run Story3.story (which is using GivenStories: Story2.story)

 

My question now is:

How can I set meta properties at the scenario level? Do you have sample code

How can I pass this to the GivenStories? Do you have sample code?

 

Thanks,

Enrique

 

From: Mauro Talevi [mailto:mauro.talevi-hQ+s5KbX5YmGglJvpFV4uA@public.gmane.org]
Sent: Tuesday, May 08, 2012 3:07 AM
To: user-b1QraVsTlj/IJWOP8RzEEmD2FQJk+8+b@public.gmane.org
Subject: Re: [jbehave-user] Using GivenStories can I turn off execution of GivenStories ran using a Meta tag?

 

Hi,

no, this behaviour is not currently available.  GivenStories are recursively run.  

What you could do is set meta properties at a scenario level which are passed to the given stories and then in your implementation take notice of these properties to run or not the relevant steps.

Otherwise, structure your given dependency tree in such a way as to avoid duplication. 

Feel free to suggest a way to configure this behaviour you're after. 

Cheers

On 08/05/2012 04:59, Jorge Pombar wrote:

I have all the stories of my project in a single folder “src/main/stories”

I’m building my test cases/stories in small blocks. So I test Story1 and then I test Story2 but it depends on Story1 to have been completed. So I’m using GivenStories:

-          Story1.story

-          Story2.story (uses GivenStories: Story1.story)

-          Story3.story (uses GivenStories: Story2.story)

 

I’m wondering if there is a way to add a meta tag on Story1 and Story2 that tells the framework not to run them because they will be run as part of Story3.story

 

Thanks for your help,

Enrique

 

 

Mauro Talevi | 9 May 2012 16:47

Re: Using GivenStories can I turn off execution of GivenStories ran using a Meta tag?

Simply declare the meta at scenario level, i.e. after the "Scenario:" keyword.  The meta properties will be automatically passed to the given stories.

Here's an example:

https://github.com/jbehave/jbehave-core/blob/master/examples/trader/src/main/java/org/jbehave/examples/trader/stories/given_stories_parametrised_by_examples.story

Cheers

On 09/05/2012 02:21, Jorge Pombar wrote:

Currently I’m half way there. On the storyPaths() method instead of using the out of the box find paths:

return new StoryFinder().findPaths(codeLocationFromClass(this.getClass()).getFile(), asList("**/" + System.getProperty("storyFilter", "*") + ".story"), null);

 

I have a separate file that lists all the story files:

Story1.story

#Story2.story

Story3.story

 

Then I have a small parser that parses this file skipping any lines commented out (my choice was #) and returns me the List I can feed into findPaths method. My return statement now looks like

return new StoryFinder().findPaths(codeLocationFromClass(this.getClass()).getFile(), myStoryList, null);

where myStoryList was the list I populated with my parser

 

So now I don’t run Story2.story (in this case) by itself. However, all the cases inside Story2.story still run when I run Story3.story (which is using GivenStories: Story2.story)

 

My question now is:

How can I set meta properties at the scenario level? Do you have sample code

How can I pass this to the GivenStories? Do you have sample code?

 

Thanks,

Enrique

 

From: Mauro Talevi [mailto:mauro.talevi-hQ+s5KbX5YmGglJvpFV4uA@public.gmane.org]
Sent: Tuesday, May 08, 2012 3:07 AM
To: user-b1QraVsTlj/IJWOP8RzEEmD2FQJk+8+b@public.gmane.org
Subject: Re: [jbehave-user] Using GivenStories can I turn off execution of GivenStories ran using a Meta tag?

 

Hi,

no, this behaviour is not currently available.  GivenStories are recursively run.  

What you could do is set meta properties at a scenario level which are passed to the given stories and then in your implementation take notice of these properties to run or not the relevant steps.

Otherwise, structure your given dependency tree in such a way as to avoid duplication. 

Feel free to suggest a way to configure this behaviour you're after. 

Cheers

On 08/05/2012 04:59, Jorge Pombar wrote:

I have all the stories of my project in a single folder “src/main/stories”

I’m building my test cases/stories in small blocks. So I test Story1 and then I test Story2 but it depends on Story1 to have been completed. So I’m using GivenStories:

-          Story1.story

-          Story2.story (uses GivenStories: Story1.story)

-          Story3.story (uses GivenStories: Story2.story)

 

I’m wondering if there is a way to add a meta tag on Story1 and Story2 that tells the framework not to run them because they will be run as part of Story3.story

 

Thanks for your help,

Enrique

 

 



Gmane