ReplaceWithVAR¶
Replace Set Variable, Create Dictionary, Create List and Catenate keywords with VAR.
Enabling the formatter
ReplaceWithVAR is not included in default formatters.
You can enable it by using --select and --extend-select options.
Variable scope¶
VAR syntax supports setting the scope of the variable with scope= parameter. It's equivalent of the following
keywords:
- Set Local Variable
- Set Task Variable
- Set Test Variable
- Set Suite Variable
- Set Global Variable
Other keywords such as Set Variable, Catenate, Create Dictionary and Create List create variable in the
local scope. Local scope is omitted by default but can be explicitly set by using explicit_local parameter.
Set Suite Variable with children=True is ignored as it is not possible to have the same behaviour with VAR.
*** Keywords ***
Custom Keyword
${var} Set Variable value
Set Local Variable ${local_variable} value
Set Task Variable ${task_variable} value
Set Test Variable ${test_variable}
Set Suite Variable ${suite_variable} value with ${value}
Set Suite Variable ${suite_variable} value with ${value} children=${True} # ignored
Set Global Variable ${global_variable} value
*** Keywords ***
Custom Keyword
VAR ${var} value
VAR ${local_variable} value
VAR ${task_variable} value scope=TASK
VAR ${test_variable} ${test_variable} scope=TEST
VAR ${suite_variable} value with ${value} scope=SUITE
Set Suite Variable ${suite_variable} value with ${value} children=${True} # ignored
VAR ${global_variable} value scope=GLOBAL
*** Keywords ***
Custom Keyword
VAR ${var} value scope=LOCAL
VAR ${local_variable} value scope=LOCAL
VAR ${task_variable} value scope=TASK
VAR ${test_variable} ${test_variable} scope=TEST
VAR ${suite_variable} value with ${value} scope=SUITE
Set Suite Variable ${suite_variable} value with ${value} children=${True} # ignored
VAR ${global_variable} value scope=GLOBAL
Catenate¶
Catenate keyword will be replaced with VAR. Separator is set using separator= parameter. Catenate keywords
can be ignored by setting replace_catenate parameter to False.
Create Dictionary¶
Create Dictionary keyword will be replaced with VAR. Variable name will change from ${name} to &{name}
to reflect the type of the variable. Create Dictionary keywords can be ignored by setting
replace_create_dictionary parameter to False.
Create List¶
Create List keyword will be replaced with VAR. Variable name will change from ${name} to @{name}
to reflect the type of the variable. Create List keywords can be ignored by setting
replace_create_list parameter to False.
Set Variable If¶
Set Variable If keyword will be replaced with IF and VAR. If value in ELSE branch is not set, implicit
${None} value will be used. Keywords with dynamic values (@{values}) are ignored since they may contain
ELSE IF and ELSE branches that should be also converted. Set Variable If keywords can be ignored by setting
replace_set_variable_if parameter to False.