Closed simonmeggle closed 2 days ago
for me this seems to be the correct behavior. the first break is in a test case, then the local scope is the test scope, the second break is in a keyword, now the local scope is the keyword scope, but you look in the suite scope. a keyword cannot see the variables in test scope. but if you came back from the keyword execution then your are back in test scope and the test scope becomes the local scope:
what did you expect?
a keyword cannot see the variables in test scope.
This is where I disagree. The User Guide states: "Variables with the test case scope are visible in a test case and in all user keywords the test uses.".
However, VAR ${local} local value
defines a variable with local scope. Even when it's defined on test level, it's not valid on the whole test scope.
Perhaps I am wrong, but during debugging I expect to have access to all variables which are listed on the left, grouped by their scope local/test/suite/global. Do you agree with that?
In the second screenshot you see Robot Framework failing correctly because I try to access such a local variable in a sub keyword. To make that work, I would need to use a kw argument and pass the local variable to the keyword.
However, on line 25 the variable inspector makes me believe that Robot Framework has access to ${local}
, which is wrong in my opinion. ${local}
here looks like a test scoped variable. But in fact it has local scope on test level.
Ah ok, now I understand. The problem here is that when robot creates a new execution context, the existing variables are simply copied into the new context. This means that each execution context has a complete copy of the variables from the parent context. This is somewhat memory-consuming, but it's easy to handle because when you want to read a variable, you don't have to consider the parent context.
In the debugger, I need to figure out the differences between the individual contexts. So, if I want to display the variables of the suite context, I take the variables from the suite context and check which of them are not in the global context. For the test context, I use the suite context. And for the local variables, I need to check if I am in a keyword and then subtract either the suite context or the test context.
Unfortunately, I cannot determine how a variable was defined, whether with VAR
+ scope or Set Global/Suite/Test Variable
or is it a local variable.
Therefore, the suite variables also show the local variables created in the suite.
I need to figure out how to do this better, so I'll leave this issue open for now.
👍 Thanks Daniel, I appreciate your efforts!
I am reproducing the example in the Robot Framework User Guide about the VAR syntax:
https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#var-syntax
Then I start the Debugger with a breakpoint here.
This is correct: the variable
${local}
is a local one:When I debug into the
keyword
Keyword, this does not seem correct to me:The Variable inspector shows
local
as a test variable, which is not true.My expectation is that the variables shown in the list are accessible at the current line. (Or am I wrong...?)