Skip to content

Latest commit

 

History

History
40 lines (29 loc) · 1001 Bytes

step_definitions.md

File metadata and controls

40 lines (29 loc) · 1001 Bytes

Step definitions

Step definitions (Given, When, Then) are the glue between features written in Gherkin and the actual tests implementation.

Cucumber supports two types of expressions:

  • Cucumber expressions
  • Regular expressions

See also the reference documentation.

Cucumber expressions

Cucumber expressions

The following Gherkin step:

Given I have 42 cucumbers in my belly

Can be implemented with following Cucumber Expression in Scala:

Given("""I have {int} cucumbers in my belly"""){ (cucumberCount: Int) =>
  // Do something    
}

Regular expressions

The following Gherkin step:

Given I have 42 cucumbers in my belly

Can be implemented with following Regular Expression in Scala:

Given("""^I have (\d+) cucumbers in my belly$"""){ (cucumberCount: Int) =>
  // Do something    
}