Details
Description
It is generally acceptable that you can describe a business case just using Given/When/Then/And suite.
However when the scenario you need to write is a long one (say 30 or more steps) I have to accept that the story starts sounding a bit to fade (say made up). It works but you would prefer it to sound more natural.
I think this could be supported if we improve jBehave to allow defining "And" synonyms with exactly the same functionality as the actual "And"?
So you can say something like this:
Given our Payments system supports SWIFT messages
When a FX transaction message arrives
And the "from" currency is USD
And the "to" currency is GBP
And the exchange rate is 0.71002
And the transaction date is the next business day
And the transaction amount is $200.00
And the payer account no is 1234567890
....
And +30 others "when" steps describing the Foreigner Exchange message
Then.....
Someone would say (me included) that if I can say "With' and "Having" are synonyms of "And" and rewrite the story like below then it would sound more natural.
Given our Payments system supports SWIFT messages
When a FX transaction message arrives
Having the "from" currency as USD
And the "to" currency as GBP
With an exchange rate of 0.71002
......
Activity
Field | Original Value | New Value |
---|---|---|
Summary | Add support for 'And' synonyms | Support synonyms of step-starting keywords |
Assignee | Mauro Talevi [ maurotalevi ] | |
Fix Version/s | 3.8 [ 19104 ] | |
Fix Version/s | 3.x [ 16979 ] |
Status | Open [ 1 ] | In Progress [ 3 ] |
Status | In Progress [ 3 ] | Resolved [ 5 ] |
Resolution | Fixed [ 1 ] |
It seems to me as most of the additional 'And' lines in your scenario are details to the first 'When' line. If I relate to Java code, this would be parameters to a factory method or a builder. Am I correct?
In that case, treat the use of 'With' as an indication that the following line relates to a previous Given/When/Then statement.
Disregarding the huge implications of changing the language, consider adding a 'With' statement that would allow us to pass parameters from that line to a builder created in the first Given/When/Then statement.
When a FX transaction message arrives: A builder of type FxTransactionMessageBuilder is created, but the actual method is NOT called
With the "from" currency as USD: builder.addFromCurrency(Currency currency)
With the "to" currency as GBP: builder.addToCurrency(Currency currency)
Then, when no more 'With' lines are found. The builder object will be created and passed as parameter to the 'When a FX transaction message arrives' method.
Would this be something to consider?