In Behavior-Driven Development, Gherkin is a specification language for defining behaviors. Gherkin scenarios can easily be automated into test cases. There are many points to writing good Gherkin, but to keep things simple, I like to focus on four major rules:
- Gherkin’s Golden Rule
- The Cardinal Rule of BDD
- The Unique Example Rule
- The Good Grammar Rule
Check out my TechBeacon article to learn about these rules in depth!
Thanks for the great post. As per the Cardinal Rule one scenario should cover one single behavior. Following that does that mean that one behavior should have only one scenario or it can have multiple scenarios? Also, Is it a good practice to use scenario outlines (examples) for a single scenario, but with different Givens & Then.
Should one behavior have only one scenario? Probably. Redundant scenarios don’t add value. However, note that the definition of “behavior” is loose. The meaning behind “one scenario, one behavior” is uniqueness – make sure each scenario covers something unique.
Also, I’m not sure what you mean when you say a scenario outlines with different Givens and Thens. Could you please provide an example?