Scenario:
A scenario is a sequence of steps represents the behavior of the application. Each feature can have one or more scenarios. The scenario start with Scenario: , scenario consists of more steps.
Example
Scenario : Add customer
Given user navigate the url in the browser
When user select the manager login
And add the customer with "username", "lastname", "postcode"
Step Definition
[Given(@"user navigate the url in the browser")]
public void GivenUserNavigateTheUrlInTheBrowser()
{
}
[When(@"user select the manager login")]
public void WhenUserSelectTheManagerLogin()
{
}
[When(@"add the customer with ""([^""]*)"", ""([^""]*)"", ""([^""]*)""")]
public void WhenAddTheCustomerWith(string username, string lastname, string postcode)
{
}
Consider If the same scenario needs to be tested for 3 different set of data then we need to create 3 scenarios
Scenario : Add customer
Given user navigate the url in the browser
When user select the manager login
And add the customer with "username1", "lastname1", "postcode1"
Scenario : Add customer
Given user navigate the url in the browser
When user select the manager login
And add the customer with "username2", "lastname2", "postcode2"
Scenario : Add customer
Given user navigate the url in the browser
When user select the manager login
And add the customer with "username3", "lastname3", "postcode3"
To optimize the scenario creation we can use Scenario Outline
Scenario Outline:
A Scenario Outline keyword is used to run same scenarios multiple times using different combinations of values.
We should define Scenario Outline with Example Table. Each and every row in the Example Table will generate a Scenario.
The syntax of scenario outline feature defined as following -:
Scenario Outline:
Given the environment
When user login with "", ""
Examples:
[Header 1 | Header 2|
| param1 | param1|
|param2 | param2|
The Header Row and Example Rows use the vertical bar symbol | to delimit columns. The Example Parameters can be used in the Step by using their name (defined in the Header Row) surrounded by < and >.
Example :
CustomerOutline.feature file -
Feature: To test the withdrawal,deposit and transaction feature
Scenario Outline: Add customer
Given user navigate the url in the browser
When user select the manager login
And add the customer with "<username>", "<lastname>", "<postcode>"
Examples:
|username |lastname |postcode |
|Tester | tester | 32334 |
|Develop | Develop | 32334 |
|Designer | Designer | 32334 |