Are Multiple Scenario Outlines in a Feature File Okay?

Recently, someone asked me:

In Gherkin, is it good or bad practice to have multiple Scenario Outlines with Examples tables in one feature file?

The short answer is yes, it is perfectly fine to have multiple Scenario Outlines within one feature file.

However, the unspoken concern with this question is the potential size of the feature file. If one Feature has multiple Scenario Outlines with large feature tables, then the feature file could become unreadable. Remember, Gherkin is a specification language, not a programming language. A feature file should look more like a meaningful behavior example than a giant wall of text or a low-level test script. Make sure to follow good Gherkin guidelines:

  • Follow the Golden Gherkin Rule: Treat other readers as you would want to be treated.
  • Follow the Cardinal Rule of BDD: One scenario, one behavior.
  • Write declarative steps, not imperative ones.
  • Try to limit the number of steps in each scenario to single digits.
  • Use only a few rows and columns per example table.

Use, but don’t abuse, the templating facet of Scenario Outlines!

2 comments

  1. well, when people have perfect scenario they tend to test it against a different set of data. Nothing wrong with it. The problem here mostly managing this set of data with gherkin – gherkin must be not the best solution for it. I think BDD tools must evolve to answer it.
    In context of gherkin I think scenario should give meaningfully example that describes behaviour of the system and that is it, but not to cover all data sets to provide test coverage. bdd tools are still misunderstood with testing tools.

    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 )

w

Connecting to %s