Scenario Outline is simply a scenario with a set of examples. Whenever you need to use the Examples section, you need to use the Scenario Outline instead of a Scenario . The difference is that a Scenario will be executed once while Scenario Outline is executed for each example from the table.
- What's the difference between scenario and scenario outline?
- What is scenario outline?
- Can we use scenario and scenario outline together?
- When would you use a scenario outline?
What's the 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.
What is scenario outline?
A Scenario Outline must contain one or more Examples (or Scenarios ) section(s). Its steps are interpreted as a template which is never directly run. Instead, the Scenario Outline is run once for each row in the Examples section beneath it (not counting the first header row).
Can we use scenario and scenario outline together?
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.
When would you use a scenario outline?
That's where the importance of scenario outline comes into picture. When we define any scenario with scenario outline, we can specify one test scenario and at the bottom of it we can provide a number of inputs. The scenario will get executed as many times as the number of inputs provided.