Cucumber Fundamentals

This course is included in the Everything IT Self-Paced training package.

Overview

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.

Target Audience

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

Prerequisites

None

Expected Duration

150 min.

Course Objectives

Course Introduction

Overview of Cucumber

  • identify how Cucumber works, list the available versions, and describe how you can install Cucumber for use with Ruby
  • Generating Features and Scenarios

  • generate Cucumber features and scenarios using Cucumber-Ruby and Gherkin syntax
  • Creating and Implementing Step Definitions

  • use regular expressions to create step definitions in Cucumber scenarios
  • Running Scenarios

  • run Cucumber scenarios and show how to use the progress formatter for more focused output
  • Using Assertions

  • use assertions in Cucumber scenarios
  • Capturing Arguments

  • use features such as capture groups, wildcards, and multiple arguments in Cucumber steps
  • Result States

  • describe the available result states for a Cucumber scenario and provide examples of scenarios containing steps that lead to these results
  • Using Backgrounds

  • use a background section in a Cucumber feature file to outline steps common to all scenarios
  • Using Doc Strings and Data Tables

  • use doc strings and data tables for data that doesn’t fit on one line in Cucumber scenarios
  • Using Scenario Outlines

  • use scenario outlines to define steps for Cucumber scenarios
  • Nesting Steps

  • nest steps in Cucumber scenarios
  • Using Transforms

  • use transforms to remove duplication in Cucumber step definitions
  • Using Helper Methods

  • describe the Cucumber World object and refactor steps into Ruby helper methods that are added to the World
  • Tagging Scenarios

  • describe the uses for tags and tag Cucumber scenarios at feature and scenario level
  • Grouping Features in Subfolders

  • group Cucumber features in subfolders and run a feature from a subfolder
  • Filtering Scenarios

  • filter Cucumber scenarios to run a subset using tags or lines
  • Using Hooks

  • use hooks in Cucumber scenarios
  • Modifying Output

  • modify the default output from Cucumber using formatters such as progress, rerun, usage and stepdef, formatting to file, and use the backtrace option
  • Creating Profiles

  • store Cucumber command line options in a YAML file and use the profile option to run them
  • Handling Asynchronous Systems

  • handle asynchronous systems in Cucumber scenarios
  • Working with Databases

  • introduce ActiveRecord, refactor a Cucumber scenario to use data, and read and write data to a database
  • Maintaining Databases

  • use transactions and truncation to clean databases for Cucumber scenarios
  • Testing REST APIs

  • test Representational State Transfer application program interfaces or REST APIs with Cucumber
  • Issues with Features and Scenarios

  • identify issues in Cucumber scenarios such as flickering scenarios; brittle and slow features; and unengaged stakeholders, identify underlying causes, and provide solutions
  • Exercise: Creating Cucumber Features for an App

    This Course is included in our Everything IT Self-Paced Training Package.

      Learn More