Eager or Lazy Bindings
@Eager
and @Lazy
annotations can be used on the following DSL steps to control when expressions are evaluated and bound to names. In the absence of either annotation, expressions will be evaluated every time they are referenced by name and discarded once used.
@Eager
Since v3.9.0
The @Eager
annotation can be used to immediately evaluate and bind the result an expression to a name. The eagerly bound value is instantly returned whenever the name is referenced.
Given @Eager time is defined by js "new Date().getTime()"
When I capture time as time 1
And I capture time as time 2
Then time 1 should be "${time 2}"
time 1
and time 2
will have the same value since time
is evaluated and bound immediately at step 1.
@Lazy
Since v3.9.0
The @Lazy
annotation can be used to evaluate and bind the result an expression to a name when that name is first referenced. The lazily bound value is returned whenever the name is referenced thereafter.
Given @Lazy time is defined by js "new Date().getTime()"
When I capture time as time 1
And I capture time as time 2
Then time 1 should be "${time 2}"
time 1
and time 2
will have the same value since time
is bound and evaluated when it is first referenced.
Default (ephemeral)
Since v1.0.0
In the absence of either annoation, the expression will be unconditionally evaluated every time the name is referenced without being saved to memory. This is the default behaviour.
Given time is defined by js "new Date().getTime()"
When I capture time as time 1
And I capture time as time 2
Then time 1 should not be "${time 2}"
time 1
and time 2
will have different values since time
is evaluated, bound and discarded at steps 2 and 3.
DSLs
The following DSLs support eager or lazy bindngs:
<name> is defined by <javascript|js> "<expression>"
<name> is defined by <javascriptRef> applied to "<argument>"
<name> is defined by <javascriptRef> applied to "<arguments>" delimited by "<delimiter>"
<name> is defined in <textRef> by regex "<expression>"
<name> is defined by the <nodeType> in <xmlRef> by xpath "<expression>"
<name> is defined in <jsonRef> by json path "<expression>"
<name> is defined by system process "<expression>"
<name> is defined by system process "<expression>" delimited by "<delimiters>"
<name> is defined by unix system process "<expression>"
<name> is defined by file "<filepath>"
<name> is defined in the <dbName> database by sql "<selectStmt>"