Mastering pro tips for writing good steps (Advanced)

In this recipe, will cover various kinds of tips for writing good, maintainable, and DRY Cucumber steps.

Getting ready

We will reuse the Rails application cucumber_bdd_how_to that we've created in the Writing your first Hello World feature (Simple) recipe, so please cd into that directory to get prepared.

How to do it...

In the following sections, a number of useful step tips will be introduced and covered exhaustively.

Flexible pluralization

  1. Let's imagine that we need to write a step that contains a singular or plural noun depending on its count:
    When the user has 1 gift
    When the user has 5 gifts
  2. Instead of implementing two similar step definitions, we can adopt a tip in Cucumber called Flexible ...

Get Instant Cucumber BDD How-to now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.