-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
With regards to VAR syntax and Set Variable there are a few behaviors that do not functionally match.
My observation is that the VAR syntax cannot change an existing variable's scope.
This is a known RF pattern:
${SOME_FUTURE_SUITE_VARIABLE} Get Time
Set Suite Variable ${SOME_FUTURE_SUITE_VARIABLE}
In order to so the same thing:
${SOME_FUTURE_SUITE_VARIABLE} Get Time
VAR ${SOME_FUTURE_SUITE_VARIABLE} ${SOME_FUTURE_SUITE_VARIABLE} scope=SUITE
Quoted from Pekka:
VAR ${X} scope=suite
not working the same way as
Set Suite Variable ${X}
is bad design and needing to use
VAR ${X} ${X} scope=suite
This:
VAR ${X}
creates a variable with an empty string as its value.
The change would backwards incompatible.
We could deprecate that behavior in RF 7.3 and require using:
VAR ${X} ${EMPTY}
Then later, possibly already in RF 8, we could change the syntax to match
Set Suite Variable
.
Here is some example code:
*** Settings ***
Documentation Examples of setting variables.
Suite Teardown Suite Teardown
*** Test Cases ***
Set Variable Test
${GET_TIME_SET} Get Time
Set Suite Variable ${GET_TIME_SET}
VAR Syntax Test - Example 1
${GET_TIME_ONE} Get Time
VAR ${GET_TIME_ONE} scope=SUITE
VAR Syntax Test - Example 2
${GET_TIME_TWO} Get Time
VAR ${GET_TIME_TWO} ${GET_TIME_TWO} scope=SUITE
*** Keywords ***
Suite Teardown
Log GET_TIME_SET: ${GET_TIME_SET} CONSOLE
Log GET_TIME_ONE: ${GET_TIME_ONE} CONSOLE
Log GET_TIME_TWO: ${GET_TIME_TWO} CONSOLE
A thought:
What if there was a syntax for setting scope of a variable?
${SOME_FUTURE_SUITE_VARIABLE} Get Time
SET ${SOME_FUTURE_SUITE_VARIABLE} scope=suite