Use of Conjunctions within BDD steps

34 views
Skip to first unread message

Gibrail Islam

unread,
Dec 16, 2019, 12:48:25 AM12/16/19
to Behaviour Driven Development
Hello everyone!

I need your opinion on use of conjunctions e.g. and within BDD steps. Here are two examples.


Scenario: Register for online banking
Given that Bill wants to register for online banking
When he registers himself
Then his application should be created in a pending state waiting for signature and approval

Scenario: Earning standard points from an Economy flight
       Given the flying distance between Sydney and Melbourne is 878 km
       And I am a standard Frequent Flyer member
       When I fly from Sydney to Melbourne
       Then I should earn 439 points


Is it a good writing practice? Let’s  say their step definitions do not violate the single responsibility principle.

I would appreciate your comments.
Regard
Gibrail

Liz Keogh

unread,
Dec 16, 2019, 4:40:42 AM12/16/19
to behaviordriv...@googlegroups.com
And is just fine; also sometimes But.

       Given the flying distance between Sydney and Melbourne is 878 km
       And I am a standard Frequent Flyer member
       But I have requested points to be passed on to my mum
       When I fly from Sydney to Melbourne
       Then I should not earn any points
       But my mum should earn 439 points.

The only time I tend to use Given twice is when I'm introducing another new context. I can't even think of the last time I used two Thens, though I wouldn't rule it out.

Given Alex is a trader
And purchased $24m options on Christmas Chocolate
Given Sid is an auditor
...

Two Whens happen very infrequently, usually because of interaction between two people or something like time passing. Again, And or But are possible:

When Jemima sets a reminder for 3 days
And 3 days passes...

That last kind of And has caused a lot of arguments about whether it's valid, but I'm cool with it if it's genuinely the interaction that causes the behaviour you're interested in.

I've also seen And and But used extensively for all Given, When and Then in full customer journeys, which isn't really BDD but is still OK in the right context.

Note though that many frameworks only support one When.

Cheers,
Liz.

--
You received this message because you are subscribed to the Google Groups "Behaviour Driven Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to behaviordrivendeve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/behaviordrivendevelopment/5c94f884-2a5e-485b-84f9-fdd817756af4%40googlegroups.com.


--

Gibrail Islam

unread,
Dec 16, 2019, 6:31:25 AM12/16/19
to behaviordriv...@googlegroups.com
Thank you so much for replying. 
I think i was not clear in my explaination. 

I am talking about use of conjunctions within steps for example

.....
Given that distance between Melbourne and Sydney is 836 kms
....
I am not talking about use of And or But for the sake of using them as additional given,when,then.
I am talking about use of "and" in middle of a step.

I have given few examples in the start of this thread.

Regards 
Gibrail 

aslak hellesoy

unread,
Dec 16, 2019, 6:43:09 AM12/16/19
to behaviordriv...@googlegroups.com
Conjunctions that combine words are fine. Conjunctions that combine phrases or statements should be split into multiple steps.

Cheers
Aslak

Robert Sabourin

unread,
Dec 16, 2019, 7:20:04 AM12/16/19
to behaviordriv...@googlegroups.com
All of your examples are a bit different.

The Melbourne and Sydney distance is 836 kms seems natural easy to parse and fine.  It could be expressed in a small data table if you like - I would probably use a scenario outline varying city1 city2 and distance.

Given it takes <distance> <dist units> to drive from <city1> to <city2>

avoids the "and" with the same meaning.  It is not better - just different.

I would not worry about this case.

HOWEVER the bank registration example is different since the final and step describes two additional states for the transaction which I would be delecate with and maybe even treat with different scripts.


Scenario: Register for online banking
Given that Bill wants to register for online banking
When he registers himself
Then his application should be created in a pending state waiting for signature and approval

Some people separate the states.

Could become something like:

(A) Scenario: Register for online banking
Given that Bill wants to register for online banking
When he registers himself
Then his application should be created in a pending state

(B) Scenairo: Authorize a Bank registration
      Give that Bill has a registration in the pending state
      When a signature is made
     Then the registration enters the awaiting approval state

(C) Scenario: Approving a new registration
    Given that Bill has a registrastion in the awaiting approval state
   When management confirms bills credit rating
   Then the account is authorized for online banking

Rob





Reply all
Reply to author
Forward
0 new messages