Bhuvnesh, You may want to use the jbehave-user email lis instead in the future - but this is fine.
As for question 1 - You are correct - @BeforeStory and @BeforeScenario work for all stories and all scenarios. The only caveat to that is story type (given or normal) or scenario type (normal or parameterized). if you're looking to execute specific code for a particular story / scenario, then you can use a Given for that. For the story - the GIven would be in the first scenario, for scenario, it would be the first Given. If that doesn't feel like what you are looking for - you could look at GIvenStories as specific prerequisites for a scenario. As for question 2 - maintaining data - I personally reset the database state using DbUnit in@BeforeStory. You can see that in the spring-security example. The state at the end of one scenario is the state for the start of the next. - if you need to refresh per scenario - then you can use DbUnit as @BeforeScenario. I like using DbUnit with Excel data files as they can handle i18n and are easy to manipulate as the schema changes. However you may have to extend DbUnit at times. I then also tend to use the services of my application for givens vs the admin screens but that is purely a personal preference. Hope that helps - thanks for using JBehave! Brian ----- Original message ----- From: "Bhuvnesh Pratap" <[1]pratap...@gmail.com> To: [2]dev@jbehave.codehaus.org Date: Wed, 22 Feb 2012 14:31:37 +0530 Subject: [jbehave-dev] Fwd: Seeking Help related to using Jbehave ---------- Forwarded message ---------- From: Bhuvnesh Pratap <[3]pratap...@gmail.com> Date: Tue, Feb 21, 2012 at 4:41 PM Subject: Seeking Help related to using Jbehave To: [4]dev@jbehave.codehaus.org Hello, First kudos to you guys for the awesome work you have been up to. I have been using JBehave + Spring + Selenium configuration while using the SeleniumConfigration provided by JBehave and have been following the etsy spring selenium example. There are couple of things I am struggling to get done and that is why feel I it's be better to ask you guys here 1) Looking at the code I noticed that all the @BeforeStory/Scenarios annotations run for all the Story/Scenario present in the purview of JBehave, I mean there doesn't seem to be any one to one corresponding between Story/Scenarios and @BeforeStory/Scenario annotations. Please correct me if I am wrong, in case this actually is the expected behavior could you please help me how to attain the one-two-one mapping of @BeforeStory/ Scenarios for the stories and the scenarios. For your reference this is what i am doing : For each text story there is a corresponding *Story.java which extends a SuperStory.java which in return extends JUnitStories. Moreover there exists a *Steps.java corresponding to each text story as well. *Steps.java are injected from a common spring bean inside the SuperStory.java.apart from this there is single LifeCycleSteps extending PerStoriesWebDriverSteps. What I am looking to achieve : I want to configure my @BeforeStory/@BeforeScenarios to configure in a way such that execution of story "x" should execute only the @BeforeStory/Scenarios of the Step "x" 2) There is another thing i want to know about which is, is there a way to maintain data across steps during the run of one particular scenario ? I mean maintaining the state/data during a scenario across the Given/When/Then. Please excuse me if I haven't used the proper channel to put up these queries. Looking forward to your response. Thanks, Bhuvnesh Pratap Singh References 1. mailto:pratap...@gmail.com 2. mailto:dev@jbehave.codehaus.org 3. mailto:pratap...@gmail.com 4. mailto:dev@jbehave.codehaus.org