small medium large xlarge

The Cucumber Book, Second Edition: Behaviour-Driven Development for Testers and Developers


Cover image for The Cucumber Book, Second Edition

The Cucumber Book, Second Edition

Behaviour-Driven Development for Testers and Developers


Your customers want rock-solid, bug-free software that does exactly what they expect it to do. Yet they can’t always articulate their ideas clearly enough for you to turn them into code. You need Cucumber: a testing, communication, and requirements tool—all rolled into one. All the code in this book is updated for Cucumber 2.4, Rails 5, and RSpec 3.5.

Customer Reviews

Few tools have managed to bridge the developer-customer divide as well as Cucumber
has. Cucumber is not a tool for testing applications. Cucumber is a philosophy for
communicating requirements. This book brings that philosophy to life.

- Robert C. Martin (Uncle Bob)

I devoured the Cucumber book on a train ride from Grenoble to Brussels a few
days after watching Matt’s presentation “BDD As It’s Meant to Be Done.” These
two resources helped me understand in just a few hours how to avoid dozens of
common mistakes writing scenarios in the Cucumber style. It’s as though I received
an injection of perhaps two years of experience writing scenarios poorly so that I
didn’t have to go through it all myself. What a gift. I recommend this book to
everyone working with Cucumber.

- J. B. Rainsberger

Author "JUnit Recipes"

Teams can use Cucumber to get a better understanding of what software to build
for their customers. In this book, Aslak and Matt do a brilliant job explaining how
you get started with Cucumber with plenty of easy-to-follow examples.

- Rachel Davies

Author "Agile Coaching"

To those of you wondering how to use Cucumber effectively, The Cucumber Book
is the answer. Not content to write just a testing book, Aslak and Matt have packed
it with practical insights on many aspects of software development. Studying this
book will make you a better software developer.

- Pat Maddox, B.D.D.M.F.

RSpec Core team

See All Reviews

Choose Your Format(s)

  • $24.95 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

What You Need

Windows, Mac OS X (with XCode) or Linux, Ruby 1.9.2 and upwards, Cucumber 2.4, Rails 5, and RSpec 3.5

Contents & Extracts

  • Cucumber Fundamentals
    • Why Cucumber? excerpt
      • Automated Acceptance Tests
      • Behaviour-Driven Development
      • Living Documentation
      • How Cucumber Works
      • What We Just Learned
    • First Taste
      • Understanding Our Goal
      • Creating a Feature
      • Creating Step Definitions
      • Implementing Our First Step Definition
      • Running Our Program
      • Changing Formatters
      • Adding an Assertion
      • Making It Pass
      • What We Just Learned
    • Gherkin Basics excerpt
      • What’s Gherkin For?
      • Format and Syntax
      • Feature
      • Scenario
      • Comments
      • Spoken Languages
      • What We Just Learned
    • Step Definitions: From the Outside
      • Steps and Step Definitions
      • Capturing Arguments
      • Multiple Captures
      • Flexibility
      • Returning Results
      • What We Just Learned
    • Expressive Scenarios
      • Background
      • Data Tables
      • Scenario Outline
      • Nesting Steps
      • Doc Strings
      • Staying Organized with Tags and Subfolders
      • What We Just Learned
    • When Cucumbers Go Bad
      • Feeling the Pain
      • Working Together
      • Caring for Your Tests
      • Stop the Line and Defect Prevention
      • What We Just Learned
  • A Worked Example
    • Step Definitions: On the Inside excerpt
      • Sketching Out the Domain Model
      • Removing Duplication with Transforms
      • Adding Custom Helper Methods to the World
      • Organizing the Code
      • What We Just Learned
    • Support Code
      • Fixing the Bug
      • Bootstrapping the User Interface
      • Making the Switch
      • Using Hooks
      • Building the User Interface
      • What We Just Learned
    • Dealing with Message Queues and Asynchronous Components
      • Our New Asynchronous Architecture
      • How to Synchronize
      • Implementing the New Architecture
      • Fixing the Flickering Scenario
      • What We Just Learned
    • Databases
      • Introducing ActiveRecord
      • Refactoring to Use a Database
      • Reading and Writing to the Database
      • Cleaning the Database with Transactions
      • Cleaning the Database with Truncation
      • What We Just Learned
  • Cucumber Applied
    • The Cucumber Command-Line Interface
      • Cucumber’s Command-Line Options
      • Running a Subset of Scenarios
      • Changing Cucumber’s Output
      • Specifying the Location of Step Definitions
      • Managing Your Work in Progress (WIP)
      • Using Profiles
      • Running Cucumber from Rake
      • Running Cucumber in Continuous Integration
      • What We Just Learned
    • Testing a REST Web Service
      • In-Process Testing of Rack-Based REST APIs
      • Out-of-Process Testing of Any REST API
      • What We Just Learned
    • Adding Tests to a Legacy Application excerpt
      • Characterization Tests
      • Squashing Bugs
      • Adding New Behavior
      • Code Coverage
      • What We Just Learned
    • Bootstrapping Rails
      • Running the Generators
      • Creating a User
      • Posting a Message
      • Associating a Message with a User
      • Creating a Controller by Hand
      • Implementing the View
      • What We Just Learned
    • Using Capybara to Test Ajax Web Applications
      • Implementing a Simple Search Without Ajax
      • Searching with Ajax
      • The Capybara API
      • Taking Screenshots
      • What We Just Learned
    • Testing Command-Line Applications with Aruba
      • Simple Interfaces
      • Our First Aruba Feature
      • Working with Files and Executables
      • Interacting with User Input
      • Using Aruba’s Ruby DSL
      • What We Just Learned


Matt Wynne is a long-standing member of the Cucumber core team, fascinated by the challenge of helping tech and business to understand one another. He’s one of the co-founders of Cucumber Ltd., the company behind Cucumber. He lives on the west coast of Scotland on an old farm with his family, two cats, their dog, and some ducks. Matt tweets from @mattwynne and @cucumberbdd.

Aslak Hellesøy is the creator of Cucumber. During his career Aslak has
worked with both small and large organizations in industries such as
telecom, trading, insurance, car manufacturing, education, and government.
Aslak is co-founder of Cucumber Ltd. He tweets
from @aslak_hellesoy and @cucumberbdd.

Steve Tooke is a programmer, trainer, and coach who is dedicated to improving his
craft and helping others improve theirs. He’s a co-founder of
Cucumber Ltd. Steve tweets from @tooky and @cucumberbdd.