A description of the step.
Cucumber executes each step in a scenario one at a time, in the sequence you’ve written them in.
When Cucumber tries to execute a step, it looks for a matching step definition to execute.
Keywords are not taken into account when looking for a step definition.
This means you cannot have a Given, When, Then, And or But step with the same text as another step.
Cucumber considers the following steps duplicates:
Given there is money in my account
Then there is money in my account
This might seem like a limitation, but it forces you to come up with a less ambiguous, more clear domain language:
Given my account has a balance of £430
Then my account should have a balance of £430
To pass arguments, description can contain placeholders in curly braces.
To match:
Given my account has a balance of £430
use:
given("my account has a balance of £{float}", function(balance, context) {
If no step definition is found an error will be thrown.
If multiple steps definitions for a single step are found an error will be thrown.
A function that will be run during test execution.
The implementation function must always have the last parameter named context.
It holds the environment where test state can be stored to be passed to the next step.
If a step has a description "I have {int} cucumbers in my basket" then the implementation
function should be function(n, context). The {int} value will be passed to
n, this parameter can have any name.
If a table or a docstring is defined for a step, it will be passed as an argument after placeholder parameters
and before context. The function should be a function(n, table, context).
See
an example
on how to write implementation that uses tables or docstrings.