Scenario Outline

In testing, we generally have scenarios where we have multiple combinations of input and different outputs for the same set of steps, such as the log-in combination and some other business calculation. Scenario Outline helps express these scenarios in a much better way by letting us express the scenario once and giving us an option to provide multiple sets of data in the Examples section. Let's take a look at the given example:

Feature: Log in


Scenario: Log in - right email/password input
Given I launch the app
When I get the user sign in screen
And I enter "[email protected]" and "valid password"
Then I should see a message "Log in success"


Scenario: Log in - wrong email input
Given I launch the app
When I get the user sign in screen
And I enter "[email protected]" and "valid password"
Then I should see a message "In-valid email provided"

Scenario: Log in - wrong password input
Given I launch the app
When I get the user sign in screen
And I enter "[email protected]" and "wrong password"
Then I should see a message "Wrong password"

In the preceding scenario, we have the same set of steps repeating for different data combinations that are the essence of the test cases. We can express the same scenario in a much better way with less repetitiveness. Refer to the following usage of Scenario Outline to achieve this:

Scenario Outline: Log in combinations
Given I launch the app
When I get the user sign in screen
And I enter <email> and <password>
Then I should see a message <message>
Examples:
|
email | password | message |
|
[email protected] | valid password | Log in success |
|
[email protected] | valid password | In-valid email provided |
|
[email protected] | wrong password | Wrong password entered |

What happens behind the scene is that Cucumber converts each example row as one scenario and executes it. So basically, the <email> is nothing but a place holder that is substituted by the real values during execution. In a feature file, we can have many Scenario Outline and Examples sections. If we create a Scenario Outline and don't include a following Example section, it will throw an error.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.134.79.121