Search code examples
bddspecflowuser-stories

How precise user stories should be?


I've just started using SpecFlow. It's a tool for creating business understandable test scenarios in a BDD manner. Basically it transforms user stories to unit tests.

I'm a beginner to user stories and I wonder about its length. Is this a good practice to create very precise user stories? Here's an example:

In order to get help
As a StackOverflow user
I want to add post
   with name and content
   and add tags to it
   and format the content
   and the information about my post edits to be stored in the system
   and some more things like that

Should I keep my stories compact? If so - how can I manage detailed requirements? Or maybe it's nothing wrong in very long and precise I want section in a user story?


Solution

  • If you could develop an entire system in a couple of weeks, and do that reliably, nobody would ever worry about "user stories". They'd just get you to develop the system, sit with you, and tweak it as it went.

    User stories only exist in order to get feedback from people who can't be with you all the time, and to help you learn what it is that your users (and other stakeholders) really want.

    Here's how I treat a list like this:

    In order to get help  
    As a StackOverflow user  
    I want to add post  
       with name and content  
       and add tags to it  
       and format the content  
       and the information about my post edits to be stored in the system  
    

    You want to get help. Which of these actually add to your ability to get help? Is it you wanting help, or do you want to offer help to other people? Do you want recognition for the help you're offering other people? The top part of this seems false (and it's why it's really difficult to have these conversations with fake requirements).

    I think there are multiple requirements here, and far beyond the scope of just one user story. With an analyst hat on, here's how I might break this down:

    In order to award great content with appropriate recognition, 
    as Stack Exchange,
    we want people's usernames to appear with their content.
    

    Of course, the users want this too, but they're not paying for it (except through adverts). So work out who's paying for this, and why.

    In order to get more page impressions and keep people on the site for longer,
    as Stack Exchange,
    we want users to be able to find similar content really easily.
    

    Hm. This one's a bit trickier. See, the user doesn't really want to spend their entire life on StackOverflow. It's just that if we give them the appropriate recognition, and make it easier for others to find their content, they might do that. Not all "user stories" actually benefit users. Find out who's paying for them, and why; then you find your real stakeholder. It's also OK for a story to benefit more than one stakeholder, and it's easy to see how to rephrase this from the user's point of view as well.

    format the content
    

    Honestly not sure about this one. It might be about being able to emphasise important points, etc. There are a ton of aesthetic ideals that don't lend themselves well to BDD and automated scenarios. Sometimes the only way to do this is to try, and get feedback.

    In order to avoid retyping my request every time
    As the user
    I want the information about my post edits to be stored in the system
    

    Well, yes, that would be nice.

    The thing is that each of these can be developed independently. If you can think of any feature, any item that you could get rid of and still have the release be valuable, put it in a separate story.

    If you can replace "I want to..." with "I want to be able to..." it's likely that what you have there isn't a story, but an entire capability. Most people do this instinctively. Lots of people call those "epics".

    I've just shown you how I break them down. It's a pretty simple process.

    First, look at your requirements. If there's anything for which you can say, "I want to be able to..." or "Someone wants to be able to..." then you know that's a completely different capability, which means it's going to be a separate story.

    You can then separate those into contexts. So you might have stories like:

    In order to free up our junior traders
    We want them to be able to generate contracts automatically
    So that they can help with the trade analysis instead of typing.
    

    If that seems too big for the feedback cycle (typically a two-week sprint), you can divide it further.

    In order to free up our junior traders
    We want them to be able to generate *orange juice* contracts automatically
    So that they can help with the trade analysis instead of typing.
    

    Here, we're focusing on being able to trade orange juice, but we could equally narrow the story down to the FTSE, or the US, or the NY stock exchange. This is how we focus the efforts on the thing that will deliver: protecting revenue, lowering costs or generating value.

    To turn these into scenarios, I ask, "Can you give me an example of an OJ trade on the NY stock exchange?" If I see anything generic that I don't understand, I ask, "Can you give me an example of that?"

    That example becomes my first scenario. The context (given) is defined by the limits of the story. The event (when) is the performance of the capability. The outcome (then) is the resulting value.

    In answer to your question - yes, I think it's important to create precise user stories. That means knowing why it's valuable, defining the context that you're going to cover, and suggesting an example of what the outcome might be.

    The example you gave is more than just one story, though. It's not precise enough. Hopefully the advice here will help you to narrow stories down to something useful. One or two days is a good length for a story, but if you're starting down this path and find they're a bit longer, that's OK.

    Your changes are also stories.