Skip to main content

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.

@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.

Eager example
  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.

Eager example
  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. This is the default behavior.