Have you considered an idempotent approach
(http://en.wikipedia.org/wiki/Idempotence)?
In your case, the CreateUser.story could check for the existence of the
user and only create one if it does not exist.
This way, you can apply it any number of times.
Otherwise, for an example of meta parametrisation, have a look at
https://github.com/jbehave/jbehave-core/blob/master/examples/trader/src/main/java/org/jbehave/examples/trader/stories/given_stories_parametrised_by_meta.story
On 07/11/2012 17:10, Chris Geer wrote:
Thanks for the response. Here is my use case:
In my system I need to manage users and have the following stories:
- CreateUser.story
- ModifyUserProfile.story
- DeleteUser.story
- ChangeUserPassword.story
ModifyUserProfile, DeleteUser and ChangeUserPassword are
all dependent on a user being present, which is created as part of
CreateUser. It would nice to be able to have CreateUser be a
GivenStory in all three of those stories so that regardless of which
one was run (or run first) CreateUser was always executed. But at the
same time, it can only be run once.
So I'm not sure the meta info would work. This is a relatively simple
scenario but it demonstrates the issue.
Chris
On Tue, Nov 6, 2012 at 12:23 PM, Mauro Talevi
<[email protected] <mailto:[email protected]>> wrote:
Hi Chris,
there is no explicit support for conditionality in GivenStories.
That said, GivenStories can be parametrised by meta (i.e. the meta
properties are passed to the given story) and you could try using
some bespoke meta info to execute or not certain stories, scenario
or steps.
Bear in mind, though, that it's not very transparent and you risk
losing a key benefit of BDD - the communication aspect.
Alternatively, still using meta, you can opt for a filtering
solution, whereby certain stories are not executed depending on
the filter you specify at runtime.
Feel free to put forward your usecases and we'll see if they can
be better satisfied and if the case exists for new features.
Cheers
On 06/11/2012 05:48, Chris Geer wrote:
We are trying to use GivenStories to ensure prerequisite
stories are run but are having a few problems. We really have
a need to be able to declare a story as a given story on
multiple stories but only have it run once, regardless of how
many times it's declared. For example, we have a story that
create a new user in the system, that if called multiple times
causes errors, however we have multiple stories that require
that user to be there. We'd like to be able to declare the
createUser.story as a GivenStory for multiple other stories
but also be able to mark it so that it's executed only once,
kind of like a singleton story.
Is that possible today? If not, is there a good workaround? I
also can't find a way to make a scenario/step/story run
conditionally.
Thanks,
Chris
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email