Advanced Cucumber
Learn about Cucumber step definitions, Cucumber features, scenario outlines, and Cucumber cautions.
This section could also be titled “Things Cucumber lets us do that are probably bad ideas.” Cucumber allows for a lot of flexibility in how steps match with step definitions. By and large, the Cucumber-using community has concluded that most of these things should be used sparingly, if at all.
Cucumber step definitions
Earlier, we learned that step definitions were regular expressions and not strings. This allows us to have the same step definition to apply to multiple strings. More to the point, we can use regular-expression groups to capture those matches. The parts of the string in groups are then passed as block variables to the block part of the step definition. This allows us to treat a Cucumber step as a method call with parameters.
Cucumber features
In the existing initial step, the project name is hard-coded inside the step definition. If, on the other hand, we wanted to be able to specify the name of the project in the Cucumber feature, we could write the step definition as follows:
Get hands-on with 1400+ tech skills courses.