Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use SpecFlow's "Scenarios" keyword?

Tags:

specflow

In my feature file, IntelliSense says that there is a keyword called Scenarios. Note that it is plural. I've poured through the documentation and can't find any references to it. Can anybody explain what it is for and how it can be used?

like image 427
Ecyrb Avatar asked Dec 05 '11 20:12

Ecyrb


People also ask

Can I use scenario outline with background?

If different groups need different backgrounds, and it's not possible to just use scenario outlines to group them, then perhaps split the specification into multiple feature files. Each file will be shorter, and it can use a more focused background section to prepare only the common aspects for its own scenarios.

What is difference between scenario and scenario outline?

Scenario outline is exactly similar to the scenario structure, but the only difference is the provision of multiple inputs. In order to use scenario outlines, we do not need any smart idea, we just need to copy the same steps and re-execute the code.


1 Answers

That's a synonym to the Examples word used in for different Scenarios using the Scenario Outline construct... Or in plain English; if you use a Scenario Outline you can list the different examples under the keyword "Examples", or under the keyword "Scenarios".

Here is an example:

Scenario Outline: eating
  Given there are <start> cucumbers
  When I eat <eat> cucumbers
  Then I should have <left> cucumbers

  Scenarios:
    | start | eat | left |
    |  12   |  5  |  7   |
    |  20   |  5  |  15  |

I didn't know that before but it's easy to spot by looking in the language file. Here you'll find all the words in the all the supported languages.

like image 143
Marcus Hammarberg Avatar answered Sep 28 '22 00:09

Marcus Hammarberg