Skip to main content

Gwen Meta

Meta specs

Meta specs are Gherkin specifications that describe what steps in features will execute and are the automation glue in Gwen. They define all the step definitions and bindings required for automation and attach to features at runtime.


Composable step definitions

Step definitions are defined as @StepDef annotated Scenarios with names that match feature steps and bodies that call out to one or many DSL steps to perform operations.


Put all your step definitions in meta to keep your features clean and free of automation concerns.

Consider the following feature step:

Feature Step

File: features/todo.feature

  Given a new todo list

A step definition for executing this step could be defined in meta as follows:


File: features/todo.meta

Scenario: a new todo list
Given my todo list can be located by css ".todo-list"
When I navigate to "${}"
Then the page title should contain "TodoMVC"
And my todo list should not be displayed

Calls DSL steps:

Notice how the name of the StepDef matches the name of the feature step (excluding the leading Given keyword). This is how step definitions bind to feature steps in Gwen; by name. Notice also that the body calls out to several DSL steps to perform the desired operations. Composing StepDefs in meta is all you need to do to make your features executable.

StepDefs with parameters

StepDefs can also be declared to accept parameters using one or more <param-name> placeholders in the declared name as follows:

Feature Step
  Then the list will contain 2 items
StepDef with a parameter
Scenario: the list will contain <expected-count> items
Given the item count can be located by css ".todo-count strong"
Then the item count should be "$<expected-count>"

Calls DSL steps:

Here the name of the StepDef matches the feature step when the value 2 (in the feature step) is substituted in place of <expected-count> in the StepDef name. This is how parameters are passed to StepDefs in Gwen; by substitution. The last step in the body extracts the parameter value with $<expected-count>.

Synchronized StepDefs

In the rare case where you might need to synchronize the execution of your StepDef to a single thread (due to resource contention or a conflict for example), you can do so by tagging it with the @Synchronized annotation. Gwen will then guarantee that only one thread will execute your StepDef at any given time when multiple features or scenarios are executed in parallel mode by concurrent threads.