Hi Igal,

First of all sorry for late response.

Let me expand my reply. Let's imagine the following feature (story):

*Feature: My very important feature*

*Scenario: My first scenario*
*Given ...*
*When ...*
*Then ...*

*@setup_create_account*
*Scenario: My second scenario with setup*
*Given ...*
*When ...*
*Then ...*


Now we create a custom StoryReporter in JBehave that in beforeScenario() 
method will know which Story is going to be executed. Thanks to this we 
know the meta @setup_create_account is present.

So we only need to search for a @Setup("create_account") annotated method 
in Java (using Spring for instance), and invoke it.

You can do the same if @setup_create_account is added at Feature level 
(using beforeStory()). We also do it for examples, it is just that we have 
a naming convection that if setup name starts with 'example_', it will be 
executed before each example.

Hope you find this useful.



Best Regards,

Rafa.



El martes, 13 de septiembre de 2016, 8:46:13 (UTC+2), Igal Epshtein 
escribió:
>
> Hi Rafa , 
>
> Thanks for your answer , so just to get it clearly , you actually put some 
> tag before scenario , and then you decide by using annotations if this 
> scenario should have an afterScenario / beforeScenario code which should be 
> executed ?
>
> Thanks
>
> On Wednesday, September 7, 2016 at 1:28:47 PM UTC+3, Rafael Jimenez wrote:
>>
>> Hi Igal,
>>
>> What we did is to use a meta tag (@Setup name/@Restore name) that 
>> depending on its location in the story file, it is executed before the 
>> story, scenario or even example.
>>
>> Basically we take advantage of a custom StoryReporter implementation that 
>> "register" the meta tag with its name, so that later in @Before/@After 
>> methods we search for a implementation of @Setup/@Restore annotation in 
>> Java.
>>
>> Unfortunately I cannot share any code snippet with you.
>>
>>
>> Best Regards,
>>
>> Rafa.
>>
>>
>>
>> El martes, 6 de septiembre de 2016, 15:59:57 (UTC+2), Igal Epshtein 
>> escribió:
>>>
>>> Currently , the @AfterScenario annotation is being executed after each 
>>> scenario or after predefined ScenarioType *(ANY , SUCCESS , FAILURE) 
>>> ...*
>>>
>>> I was wondering if there a way (workaround) to execute AfterScenario 
>>> after *specific* scenario / scenarios ...
>>>
>>> Thanks
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"JBehave Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send an email to [email protected].
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/jbehave-dev/98d2134b-26d2-47be-9846-27ecb7f245bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to