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!

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

    Liked by 1 person

  2. Hola cómo estás

    En este sentido como se validan los registros de un formulario? si son requeridos o cantidad de caracteres válidos?

    estoy un poco confundida

    Like

    1. Hi LUZMA! Remember, if you can describe it, then you can do it. If you want to cover form validation, then I recommend writing scenarios to check the desired validation on each field.

      Like

  3. For a single scenario outline having multiple Examples data tables with different tagging is it fine or not? and will it work?

    Like

Leave a comment