Search code examples
c#automationbddspecflow

Specflow: How to apply one example table to more than on Scenario outline


I Have a feature file with many different scenarios and I want to be able to feed my test data table into them. Many of these scenarios will be using the same data (i.e. a set of Personas)... I don't want to have to repeat the Examples table each time under the scenario outline.

I know you can use a regular data table in the Background, but I still want to be able to use scenario outlines which require an Example table.

Any one have any ideas on how to best handle this?


Solution

  • Gherkin doesn't provide a syntax to share scenario outline examples across scenarios.

    SpecFlow+ (SpecFlow+Excel) has a feature, that allows you to attach the same Excel table to multiple scenarios:

    @source:PersonaExamples.xlsx
    Examples:
    | Persona Name | Favorite Color |
    

    You can find more examples here: http://www.specflow.org/plus/excel/getting-started/

    And more documentation about SpecFlow+Excel here: http://www.specflow.org/plus/documentation/SpecFlowPlus-Excel/