DEV Community

Discussion on: Engineering guide to writing correct User Stories

Collapse
 
finnhvman profile image
Bence Szabo

Very good article! πŸŽ‰

I wonder how you manage really complex situations? Let me try to describe it with a dumb example. Imagine you're writing specs for an app similar to instagram (and with really fine-grained control), and you end up writing a scenario like:

  Scenario: get notified of a new reaction
    Given I posted a picture on my account
    And people are allowed to react on the picture
    And notifications for reactions is turned on
    ...
    And someone liked the picture
    When I login
    Then a popup is shown that someone reacted to my picture

I remember working with scenarios that had like 10 Given statements or so. And I couldn't really see how the number of statements could have been reduced.

Collapse
 
sobolevn profile image
Nikita Sobolev • Edited

You have to apply abstraction to merge several steps together. Or apply decomposition to separate them. Let me explain, please.

For example: you want to be notified when someone posts likes on your posts/images/etc. We all know and love this feeling. For this situation it does not really matter how did you create this content. You only write specs for the reaction part.

Feature: authors are notified about readers' reactions

Scenario: get notified of a new reaction
   When a reader reacts on author's content
   Then author gets a notification about it

Scenario: do not get notified about new reactions when notifications are disabled
   When author's notifications for reactions are disabled 
   And a reader reacts on author's content
   Then author gets no notification about it

This is a first feature: receiving notifications. Disabling the ability to react is a different feature. And should be specified as a different feature. Because notifications only make sense when readers are allowed to posts reactions. However, you can mention that all content for feature authors are notified about readers' reactions is allowed to be reacted on. You can use Background tag for that: relishapp.com/cucumber/cucumber/do...

I hope this helps you.

Collapse
 
finnhvman profile image
Bence Szabo

Thanks for the reply!

Then this implies to me that I might end up writing long Backgrounds.

Do you maybe know some mature open source projects where they're doing BDD the right way? I would love to analyze something in depth.

Thread Thread
 
sobolevn profile image
Nikita Sobolev

Nope, sorry :sad:

Collapse
 
jonlauridsen profile image
Jon Lauridsen

I only know the theory, but I think the scenario setup can be abstracted in the direction you talk about it in the office. That is, do you go around saying β€œlet’s make a great notification feature for posts with notifications enabled and permissions are allowed and the user clicks etc etc”? No, you have some shorthand that the organisation accepts (or is ready to adopt). Internal language can have deep meaningful abstractions and that worth capitalising on. The BDD part of Gurkins is to identify those ways of talking.

Well, I think so at any rate. I think your question is really good and gets to the heart of the complexities with full behavioural test coverage.