The scenario step connector

Step methods start with a line that connects the scenario step to the step method itself. In Cucumber, the scenario step is referred to as a Cucumber expression.

The scenario step connector has the following syntax:

@keyword("^scenarioStep$")

where:

  • @ is a literal character.
  • keyword is a Gherkin keyword, typically Given, Then, or When.
  • ("^ and $") are literal characters that delimit the method name.
  • scenarioStep is the Cucumber expression for the corresponding scenario step.

For example:

@When("^I complete the activity$")

A step method can be used anywhere in a scenario, regardless of the Gherkin keyword used in the scenario step connector. For example:

  • You could use the Given keyword in a scenario step connector, and then use that method in a When step.
  • You could use the And keyword in a scenario step connector, and then use that method in a Then step.

Wherever possible, Guidewire recommends using only the Given, Then, or When keywords in scenario step connectors. This helps to clarify if the primary purpose of the method is to create pre-conditions, execute actions, or verify that actions executed correctly.

Input parameters

When a method has an input parameter, the parameter is named in the scenario step connector and delimited by a special set of characters. The meaning of these characters is defined by the Gherkin language. The following table lists common character sets used in the base configuration step methods. For a complete description of character meanings, refer to the Cucumber documentation.

Character String Meaning Example
("^ Start of the method name @When("^I complete the activity$")
$") End of the method name @When("^I complete the activity$")
\"([^\"]*)\" String parameter whose value is any text (Technically, this expression means “any character - except a double quote - that occurs zero or more times inside double quotes”.) @When("^the payment plan of the policy is changed to \"([^\"]*)\"$")
\"(X|Y)\": Portion of a string parameter whose value is either X or Y

@Given("^an account of type \"(Person|Company)\":$")

(?:X|Y) Portion of a string parameter whose value is either X or Y

@When("^(?:a|1) policy is added to this account$")

\"(\\d+)\" Numeric parameter (any set of digits) @Then("^a maximum of \"(\\d+)\" invoices are generated$")
\"(\\d+%)\" Percent parameter (any set of digits followed by a "%") @Then("^one invoice with \"(\\d+%)\" down is created$")