Hans Schwäbli
2013-11-22 13:43:43 UTC
I would like to discuss best practices in using JBehave/BDD concerning
story writing. So I will assert some best practices now as a JBehave/BDD
beginner.
Some of them I discovered online (various sources). I left the
justifications.
How do you think about it? Do you have any additional best practices for
story writing with JBehave?
1. Stories may be dependent of each other. If so, they must declare
their dependencies.
2. Each story typically has somewhere between five and twenty scenarios,
each describing different examples of how that feature should behave in
different circumstances.
3. Each scenario must make sense and be able to be executed
independently of any other scenario. When writing a scenario, always assume
that it will run against the system in a default, blank state.
4. Each scenario typically has somewhere between 5 and 15 steps (not
considering step multiplification by example tables).
5. A scenario should consist of steps of both types: action ("Given" or
"When") and verification ("Then").
6. Each scenario, including example table, should not run longer than 3
minutes.
7. Steps of type "Given" and "When" should not perform a verification
and steps of type "Then" should not perform actions.
8. Step names should not contain GUI information but be expressed in a
client-neutral way wherever possible. Instead of "*Then a popup window
appears where a user can sign in*" it would be better to use "*Then the
user can sign in*". Only use GUI words in step names if you intend to
specifically test the GUI layer.
9. Step names should not contain technical details but be written in
business language terms.
10. Use declarative style for your steps instead of imperative (see the
example in "The Cucumber Book" page 91-93).
11. Choose an appropriate language. If your requirements specification
is in French for instance and most of the business analysts, programmers
and testers speak French, write the stories in that language.
12. Don't mix languages in stories.
13. Use comments sparingly in stories.
14. Avoid too detailed steps like "*When user enters street name*".
15. Don't use step aliases for different languages. Instead choose just
one language for all your stories.
16. Use step name aliases sparingly.
17. Prioritize your stories using meta information so that only high
priority stories can be executed if required.
story writing. So I will assert some best practices now as a JBehave/BDD
beginner.
Some of them I discovered online (various sources). I left the
justifications.
How do you think about it? Do you have any additional best practices for
story writing with JBehave?
1. Stories may be dependent of each other. If so, they must declare
their dependencies.
2. Each story typically has somewhere between five and twenty scenarios,
each describing different examples of how that feature should behave in
different circumstances.
3. Each scenario must make sense and be able to be executed
independently of any other scenario. When writing a scenario, always assume
that it will run against the system in a default, blank state.
4. Each scenario typically has somewhere between 5 and 15 steps (not
considering step multiplification by example tables).
5. A scenario should consist of steps of both types: action ("Given" or
"When") and verification ("Then").
6. Each scenario, including example table, should not run longer than 3
minutes.
7. Steps of type "Given" and "When" should not perform a verification
and steps of type "Then" should not perform actions.
8. Step names should not contain GUI information but be expressed in a
client-neutral way wherever possible. Instead of "*Then a popup window
appears where a user can sign in*" it would be better to use "*Then the
user can sign in*". Only use GUI words in step names if you intend to
specifically test the GUI layer.
9. Step names should not contain technical details but be written in
business language terms.
10. Use declarative style for your steps instead of imperative (see the
example in "The Cucumber Book" page 91-93).
11. Choose an appropriate language. If your requirements specification
is in French for instance and most of the business analysts, programmers
and testers speak French, write the stories in that language.
12. Don't mix languages in stories.
13. Use comments sparingly in stories.
14. Avoid too detailed steps like "*When user enters street name*".
15. Don't use step aliases for different languages. Instead choose just
one language for all your stories.
16. Use step name aliases sparingly.
17. Prioritize your stories using meta information so that only high
priority stories can be executed if required.