The Issue

We would like to check the basic integrity of Cucumber step definitions.

  • Are they all defined?
  • Are any duplicated or ambiguous?

The Answer

Use the Cucumber ‘–dry-run’ argument.

In the HTML report Cucumber will indicate undefined steps and suggest a step definition returning ‘pending’.  Duplicate or ambiguous step definitions will also be shown with all possible step definitions and their locations.

Our cucumber report shows the undefined step and ambiguous step definition errors.

Our cucumber report shows the undefined step and ambiguous step definition errors.

If you want to see it in the console add ‘-f pretty’ or don’t specify any format.

The ambigious cucumber match is causing an error in our ruby/selenium/webdriver script.

The ambigious cucumber match is causing an error in our script.

The suggested definitions for those undefined appear at the end of the output.

The undefined steps produce suggested Cucumber snippets to wrap around our Ruby/Watir script.

The undefined steps produce suggested Cucumber snippets.

The Result

You are left with a quick, easy way to do a sanity check on your Cucumber Ruby Webdriver step definitions. If you are trying to debug a test script, check out our post on using binding.pry for debugging purposes.