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!