-
-
Notifications
You must be signed in to change notification settings - Fork 7
String Interpolation
Branko Juric edited this page Jan 19, 2016
·
45 revisions
It is often useful to reference named properties and reuse string literals throughout your features. Gwen provides two interpolation mechanisms for doing this:
Interpolation occurs in the interpreter on every step in a feature before it is passed to the embedded engine for execution.
For interpolation purposes, a named value can be any one of the following:
- A system property
- Passed to Gwen through a
-D
JVM argument
- Passed to Gwen through a
- A user setting
- A runtime setting
- A launch property
- A property in a properties file passed to Gwen through the
-p
or--properties
launch option
- A property in a properties file passed to Gwen through the
- A bound attribute
- An attribute bound in the local, global, or current data scope
- For example, the
my ???
attributes in the samples below are all bound attributes
Substitution involves replacing named value placeholders in a single string with their resolved values.
Feature: String Interpolation
Scenario: By Substitution
Given my mechanism is "substitution"
And my value is "${my.property}"
When my proposition is "By ${my mechanism} my value is ${my value}"
Then my proposition should be "By substitution my value is ${my.property}"
Concatenation involves joining string literals and resolved named values together to form a single string.
Feature: String Interpolation
Scenario: By Concatenation
Given my mechanism is "concatenation"
And my value is "" + my.property
When my proposition is "By " + my mechanism + " my value is " + my value
Then my proposition should be "By concatenation my value is " + my.property