Udemy REST Assured free

Use of Rule in Cucumber

The purpose of the Rule keyword is to  represent one business rule that should be implemented.

  • It group together several scenarios that belong to same business rule.
  • It provides additional information for a feature. 
  • It has been added in Gherkin v6. 
  • This is Optional Keyword.
  • A Rule should contain one or more scenarios that illustrate the particular rule.
  • The Rule keyword is simply a grouping construct.

Note: Gherkin 6 has not yet been incorporated into all implementation of Cucumber! Rule keyword is not available in Cucumber version 4 and 5. 

Example of Rule

@tag
Feature: Title of your feature
	
  Rule:
  - VAT is 25%
  - Delivery for basket under $50 is $5
  - Delivery for basket over $100 is $2 
  
  @tag1
  Scenario: Title of your scenario
    Given I want to write a step with precondition
    And some other precondition
    When I complete action
    And some other action

Video Tutorial: Rule Keyword in Cucumber