String Interpolation
Since v1.0.0
It is often useful to reference settings, captured values and other text throughout your feature and meta files. To support this, Gwen provides a placholder substitution mechanism.
Placeholders
A placeholder can be:
- An environment variable name (since gwen-web 2.36.0)
- example:
${env.USER}
for theUSER
variable
- example:
- A system property name
- A Gwen setting name
- A named attribute bound to an accessible scope
Examples
Interpolation by Substitution
Substitution involves replacing named placeholders with their values.
Feature: String Interpolation
Scenario: By Substitution
Given my mechanism is "substitution"
And my value is "${my.property}"
And my proposition is "By ${my mechanism}, my value will be ${my value}"
Then my proposition should be "By substitution, my value will be ${my.property}"
Interpolation by Concatenation
Deprecated
Concatenation involves joining string literals and named values together.
Feature: String Interpolation
Scenario: By Concatenation
Given my mechanism is "concatenation"
And my value is "" + my.property
And my proposition is "By " + my mechanism + ", my value will be " + my value
Then my proposition should be "By concatenation, my value will be " + my.property