Skip to Main Content
Cucumber Recipes
book

Cucumber Recipes

by Ian Dees, Matt Wynne, Aslak Hellesoy
February 2013
Intermediate to advanced content levelIntermediate to advanced
272 pages
5h 45m
English
Pragmatic Bookshelf
Content preview from Cucumber Recipes
Recipe 3Run Slow Setup/Teardown Code with Global Hooks

Problem

You need to do something that takes a while before your first test, such as launching a browser or waiting for a desktop application to load. You’re familiar with Cucumber’s Before hook, which runs once per scenario. But you want something that runs just once overall so that your setup code doesn’t slow down your test too much.

Ingredients

  • Cucumber’s built-in env.rb file for setup code

  • Ruby’s built-in at_exit hook for teardown code[22]

  • The Selenium WebDriver browser automation library[23]

  • The Firefox web browser[24]

Solution

This recipe starts with a simple web testing project. Before we make our improvements, the code to start and stop the web browser executes inside regular ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Cucumber Cookbook

Cucumber Cookbook

Shankar Garg
Basiswissen Softwaretest , 6th Edition

Basiswissen Softwaretest , 6th Edition

Andreas Spillner, Tilo Linz
React Cookbook

React Cookbook

David Griffiths, Dawn Griffiths

Publisher Resources

ISBN: 9781941222607Errata