Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing a common set of Examples across multiple Scenario Outlines in Specflow

Is is possible to share a common set of examples across multiple scenario outlines in Specflow without duplicating the set of examples for each outline?

e.g. excuse the noddy example, but here the Examples are repeated for each Scenario Outline and I want to know if it's possible to declare those Examples once and use them for each Scenario Outline?

Feature: Just an example about animals

Scenario Outline:
    Given an <animal>
    When something happens 
    Then this should be the outcome

    Examples:
    | animal |
    | Dog |
    | Cat |

Scenario Outline:
    Given an <animal>
    When something different happens
    Then this other thing should be the outcome

    Examples:
    | animal |
    | Dog |
    | Cat |
like image 573
AdaTheDev Avatar asked Nov 14 '11 11:11

AdaTheDev


People also ask

Can we have multiple examples for same scenario outline?

Each scenario outline can have multiple tables with examples. The parameters in scenario outlines allow test runners to paste the examples from the table into the outline.

Can we have multiple scenario outlines in one feature file?

Feature files can have more than one Scenario or Scenario Outline. You can write all your possible requirements or Scenarios for a particular feature in a Feature File. One Scenario is separated from another using the "Scenario" or "Scenario Outline" keyword.

How do you add multiple scenarios in SpecFlow feature file?

@Nir Multiple scenarios can be added by just specifying a new Scenario: tag. Scenario outline is detailed in the SpecFlow docs on their site. Without really understanding what it is you want to parameterise, I can't offer a code sample.

How do I pass data from one scenario to another in SpecFlow?

If you have data valid for the whole feature, place it in the feature context. But this data can't be modified in one scenario and accessed in another. The tests will be executed in an order determined by your test runner. Different runners may choose different orders.


1 Answers

It appears this is not actually possible in SpecFlow.

like image 119
AdaTheDev Avatar answered Sep 28 '22 23:09

AdaTheDev