Skip to main content

Gwen DSL

DSL Steps

Every Gherkin step that matches a prescribed DSL is readily executable by Gwen.

Example

The following is a DSL Step:

  Then the page title should contain "TodoMVC"

Since it matches:

All execution happens in the DSL

Every step interpreted by Gwen will either directly or inderectly through StepDefs, result in:

  • One or many DSL steps being executed
  • One or many undefined steps being reported
  • Or a combination of the above

If you've got everything right, all steps will execute. It is your job as a Gwen user to define StepDefs for every non DSL step in your features (and in your meta if you introduce any there).

tip

Use dry runs to check for syntax and binding errors and identify any missing StepDefs before committing to an automation cycle.

Step execution rules

Gwen interprets steps for execution according to the following rules:

  1. StepDef rule
    • If the step is bound to a StepDef then apply these rules to every step in the body of that StepDef
  2. DSL rule
    • If the step is a DSL step then execute it using built-in code
  3. Undefined rule
    • If neither of the above rules are satisfied then report an undefined step error

Compose StepDefs with DSL steps

To make the following feature step executable:

Step in feature

File: features/todo.feature

  Given a new todo list

You could compose a StepDef as follows:

StepDef in meta

File: features/todo.meta

  @Context
@StepDef
Scenario: a new todo list
Given my todo list can be located by css ".todo-list"
When I navigate to "https://todomvc.com/examples/react"
Then the page title should contain "TodoMVC"
And my todo list should not be displayed

Calls DSL steps: