What is the purpose of a Scenario Outline in Cucumber?

A Scenario outline is a way of parameterization of scenarios. This is ideally used when the same scenario needs to be executed for multiple sets of data, however, the test steps remain the same. Scenario Outline must be followed by the keyword ‘Examples’, which specify the set of values for each parameter.

A scenario outline replaces an identifier with the actual value from the table. Each row can be considered as a scenario. A feature file is more time taking a task and is more error-prone in testing. The same feature file can be reduced to less number of lines for execution in the scenario outline feature to increase the efficiency and decreases the runtime.

How to declare Scenario Outline inside feature file

Feature: Registration, Login and MyAccount

  Scenario Outline: Verify Login Functionality
    Given I am on the homepage
    And I follow "Sign in"
    And I fill "email address textbox" with "<email>"
    And I fill "password textbox" with "<password>"
    And I click "sign in button"
    Then I should see "<heading>" heading

      | email                     | password | heading        |
      | goswami.tarun77@gmail.com | test1234 | MY ACCOUNT     |
      | wrongusername             | test     | AUTHENTICATION |

Here email, password and heading will be replaced with values in example section during execution.