Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Cucumber Cookbook
  • Table Of Contents Toc
Cucumber Cookbook

Cucumber Cookbook

By : Shankar Garg
3.7 (3)
close
close
Cucumber Cookbook

Cucumber Cookbook

3.7 (3)
By: Shankar Garg

Overview of this book

This book is intended for business and development personnel who want to use Cucumber for behavior-driven development and test automation. Readers with some familiarity with Cucumber will find this book of most benefit. Since the main objective of this book is to create test automation frameworks, previous experience in automation will be helpful.
Table of Contents (8 chapters)
close
close
7
Index

Adding Hooks to Cucumber code

After finding out how to run a few selective Features, the next great thing is running some code before or after test Scenarios. These are very basic and desired Features for Test Automation Frameworks. Examples of this could be initializing the browser before the execution starts and closing the browser after the execution is complete. So how do we do this in Cucumber? Let's take a look at this in this recipe.

Getting ready

For this recipe, we are going to update the home_page.feature file to the one shown as follows:

Feature: Home Page

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

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

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

How to do it…

  1. In the automation package, create one java class Hooks.java and put the following...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Cucumber Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon