Cucumber Fundamentals

Developers familiar with Ruby, who want to use Cucumber to create text-based feature requirements and documentation and run automated acceptance tests


Expected Duration
152 minutes

Cucumber is a tool that supports behavior-driven development. Stakeholder requirements can be specified using plain text within features and scenarios, which can then be used for automated testing during development and for documentation when the product has been developed. While scenario steps are generated using plain text with a structure provided by a syntax called Gherkin, the steps that make up the scenarios are matched with step definitions coded in the language of the underlying platform. Cucumber is implemented for a number of different platforms including Ruby, Ruby on Rails, Java, Clojure, and Python. This learning path will cover how to create features and scenarios and steps using Cucumber-Ruby. You will learn how to optimize and organize features and scenarios. You’ll learn how to work with message queues, asynchronous behavior, and databases. You’ll also learn how to test Representational State Transfer application program interfaces or REST APIs using Cucumber, and you’ll learn how to troubleshoot Cucumber scenarios.


Getting Started with Cucumber

  • start the course
  • identify how Cucumber works, list the available versions, and describe how you can install Cucumber for use with Ruby
  • generate Cucumber features and scenarios using Cucumber-Ruby and Gherkin syntax
  • use regular expressions to create step definitions in Cucumber scenarios
  • run Cucumber scenarios and show how to use the progress formatter for more focused output
  • use assertions in Cucumber scenarios

Working with Step Definitions

  • use features such as capture groups, wildcards, and multiple arguments in Cucumber steps
  • describe the available result states for a Cucumber scenario and provide examples of scenarios containing steps that lead to these results

Developing Expressive Scenarios

  • use a background section in a Cucumber feature file to outline steps common to all scenarios
  • use doc strings and data tables for data that doesn’t fit on one line in Cucumber scenarios
  • use scenario outlines to define steps for Cucumber scenarios
  • nest steps in Cucumber scenarios

Optimizing Scenarios

  • use transforms to remove duplication in Cucumber step definitions
  • describe the Cucumber World object and refactor steps into Ruby helper methods that are added to the World
  • describe the uses for tags and tag Cucumber scenarios at feature and scenario level

Managing Scenarios and Features

  • group Cucumber features in subfolders and run a feature from a subfolder
  • filter Cucumber scenarios to run a subset using tags or lines
  • use hooks in Cucumber scenarios
  • modify the default output from Cucumber using formatters such as progress, rerun, usage and stepdef, formatting to file, and use the backtrace option
  • store Cucumber command line options in a YAML file and use the profile option to run them

Messaging and Asynchronous Behavior

  • handle asynchronous systems in Cucumber scenarios

Databases and Web Services

  • introduce ActiveRecord, refactor a Cucumber scenario to use data, and read and write data to a database
  • use transactions and truncation to clean databases for Cucumber scenarios
  • test Representational State Transfer application program interfaces or REST APIs with Cucumber

Troubleshooting Scenarios

  • identify issues in Cucumber scenarios such as flickering scenarios; brittle and slow features; and unengaged stakeholders, identify underlying causes, and provide solutions

Practice: Using Cucumber

  • create Cucumber scenarios for an app





Multi-license discounts available for Annual and Monthly subscriptions.