Returning Results

Cucumber is a testing tool, and it’s in the Ruby code of a step definition where our tests find out whether a step has succeeded in whatever it set out to do. So, how does a step definition tell Cucumber whether it passed or failed?

images/scenario-execution-flow.png
Figure 5. How Cucumber executes a scenario

Like most other testing tools, Cucumber uses exceptions to communicate the failure of a test. As it executes a scenario, one step at a time, Cucumber assumes that a step has passed unless its step definition raises an exception. If a step passes, it moves on to the next step. Figure 5, How Cucumber executes a scenario shows how this plays out.

In Cucumber, ...

Get The Cucumber Book now with O’Reilly online learning.

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