BDD: More than just behaviour driven development
Quite often when looking at BDD scenarios and objectives we can miss the key point about why we do it and the real benefit it can give to development teams. That is if the behaviour can be expressed to a wide enough audience then it becomes more valuable both in terms of long term robustness and the effective nature as Real Time Documentation.
Real Time Documentation has the advantage that it never goes out of date like that of Wiki type documentation, and typically cannot lie if written correctly! But not all BDD scenarios represent Real Time Documentation!
I always suggest creating scenarios which have the most amount of power in terms of audience, suitability for Real Time Documentation and least amount of immediate change needed.
An example of BDD scenarios and compatibility to Real Time Documentation
1) The Poor BDD Scenario
Load Page 'xyz.html'Enter 'foo' in '\\div[3]\p[5]\table\tr[1]\td[1]'
Assert 'specific error message'
Please notice:
- It is readable only to a technical audience
- It is extremely brittle and should fail on the slightest number of changes
- It cannot be easily read grammatically and what it is meant to achieve in terms of behaviour is not clear
- It would be hard to a tester or developer to maintain this test
- This scenario is not suitable as Real Time Documentation.
2) The average BDD Scenario
Given we go to the login page
When we enter 'foo' into field 'j_password'
Then we should get 'x_errors' value 'com.custom.LoginException foo is not recognised as a known'
Please notice:
- The scenario is readable to a larger audience but the terms involved make it appear very techie.
- The test is much less brittle but it still relys on development criteria
- It can be read grammatically but again is far too techie
- It can be maintained more easily than the first scenario. But the references to the fields and Exception messages make it far more brittle than it needs to be
- The scenario has average suitability for Real Time Documentation
3) The ideal BDD Scenario
Given we go to the login pageWhen an unknown username is entered
Then an error message should be displayed
Please note:
- The scenario is grammatically readable to technical and business audiences
- The scenario is not brittle (although care should be taken in the underlying code to prevent passing this further down the line)
- The scenario is unlikely to have to change that often
- The scenario is ideal for Real Time Documentation.
No comments:
Post a Comment