Book Image

Cucumber Cookbook

By : Shankar Garg
Book Image

Cucumber Cookbook

By: Shankar Garg

Overview of this book

Table of Contents (13 chapters)
Cucumber Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

ANDing and ORing tagged Hooks


Just as we ANDed and ORed the Tags, same way we can AND and OR the combination of Tags and Hooks. Consider a situation where we need to perform certain Steps for Features, such as for feature1 and feature2 but not for other Features. How do we do this in Cucumber? Let's see this in this recipe.

Getting ready

We will update the home_page.feature file like this for this recipe:

@important
Feature: Home Page

  Background: flow till home page
    Given user is on Application home page

  @sanity
  Scenario: Home Page Default content
    Then user gets a GitHub Bootcamp section

  @regression
  Scenario: GitHub Bootcamp Section
    When user focuses on GitHub Bootcamp Section
    Then user gets an option to setup git

  @sanity @regression
  Scenario: Top Banner content
    When user focuses on Top Banner
    Then user gets an option of home page

How to Do it

  1. To run the Hook code before Scenarios Tagged with @sanity or @regression, add the following code to the hooks...