4 Rules for Writing Good Gherkin

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:

  1. Gherkin’s Golden Rule
  2. The Cardinal Rule of BDD
  3. The Unique Example Rule
  4. The Good Grammar Rule

Check out my TechBeacon article to learn about these rules in depth!

3 comments

  1. 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.

    Like

    1. 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.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s