Hi fellow robots,
I’m seeking guidance regarding a recommendation from Robocop (the Robot Framework linter) and the limitations I’m encountering when trying to adhere to modern variable assignment practices.
Robocop frequently raises the DEPR05 warning - documenation:
DEPR05 Set Suite Variable used instead of VAR
This correctly identifies that the deprecated after robot 7.0 Set Suite Variable (or Set Global Variable) are discouraged in favor of the newer, more concise VAR syntax.
The warning in Builtin library:
NOTE: It is recommended to use the
VARsyntax introduced in Robot Framework 7.0 for creating variables in different scopes instead of the Set Global/Suite/Test/Local Variable keywords. It makes creating variables uniform and avoids all the problems discussed above.
However, I rely on setting variables dynamically within a Suite Setup that need to be accessed by subsequent test cases in the suite.
For example,
When I attempt to follow Robocop’s recommendation and use the VAR syntax:
*** Test Cases ***
Create Title
VAR ${TITLE_CAPTION}= Generate Readable Username # this robocop recommended to use
...
Search Title
Search ${TITLE_CAPTION} # Fails: Variable '${TITLE_CAPTION}' not found.
The variable ${TITLE_CAPTION}, when defined using VAR, is strictly test-local in scope and is destroyed after the first test case finishes.
Therefore, for dynamic variables that must persist across an entire suite or globally, I am forced to fall back to the “deprecated” approach:
Code snippet
*** Test Cases ***
Create Title
${token}= Advertiser.Prepare Advertiser Test Context
Set Suite Variable ${AUDIENCE_TOKEN} ${token} # This works, but triggers DEPR05 (VAR linter)
My questions:
-
Is there a modern, Robocop-compliant syntax (like VAR) that allows explicit control over the scope (e.g., Suite or Global)?
-
If not, should the Robocop rule DEPR05 be softened or retired for cases where dynamic assignment of Suite/Global variables is necessary, acknowledging that Set Suite Variable is currently the only non-Python method available?