Home > Mobile >  How to use examples mentioned in cucumber scenario in Background statement
How to use examples mentioned in cucumber scenario in Background statement

Time:03-18

The aim is to use examples mentioned in the scenario to be used in the background given statement in a feature file.

following is the feature file for reference

Feature:  As a user with a valid credentials i should view awards and select products for cart

  Background: 
    Given an authenticated logged in user with valid <username> and <password>
  
  @smoke
  Scenario: Bot should display awards
     When the user is checks for award section
     Then User is presented with awards earned
  
    Examples: 
      | username | password | 
      | username | password | 
  
  @smoke
  Scenario: bot should select the proper product
     When the user chooses product to buy
     Then User is presented with cart with selected product.
  
    Examples: 
      | username | password | 
      | username | password | 

CodePudding user response:

Afaik you cannot use variables from your examples in the background. In your example, if you need different logins, you'll need to make that a step in your actual scenario.

CodePudding user response:

Cucumber doesn't support scenario outline in background. You need to define that in the scenario, which means if you want to user scenario outline you can't use that step in Back ground. Here is the update from cucumber team regarding this featureenter link description here: https://github.com/cucumber/common/issues/469

  • Related