O'Reilly logo

Instant Cucumber BDD How-to by Wayne Ye

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required