Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables set using Set Suite Variable with children=True cannot be properly overwritten #4964

Closed
oetzus opened this issue Dec 1, 2023 · 2 comments

Comments

@oetzus
Copy link

oetzus commented Dec 1, 2023

I noticed that when "Set Suite Variable" is used with children=${True} in a suite setup and is then overwritten again within the the test case, the variable still has the old value when logged in a separate keyword. To better explain it, here's a simple test case to reproduce the error:

*** Settings ***
Suite Setup    Test Suite Setup

*** Test Cases ***
Variable Test
    Log    ${test_variable}
    Set Suite Variable    \${test_variable}    test case level content
    Log    ${test_variable}
    Check Variable

*** Keywords ***
Test Suite Setup
    Set Suite Variable    \${test_variable}    suite setup level content    children=${True}
    Log    ${test_variable}
    Check Variable

Check Variable
    Log    ${test_variable}

In the suite setup, the suite variable ${test_variable} is set using children=${True}. Logging the variable directly afterwards and additionally in the separate keyword "Check Variable" returns the correct value "suite setup level content".
Then in the test case, the suite variable is overwritten with "test case level content". Logging the variable before that step returns "suite setup level content" and after overwriting the variable the logging returns "test case level content" as expected.
However, when executing "Check Variable" again in the test case, the value is again "suite setup level content", so the old value instead of the new.

You may say now that the "children" parameter does not make sense to use on this level, but the same problem also occurs when I set the suite variable on a higher level in the init.robot file. Only because of simplicity I did it now in the suite setup of the same robot file. But nonetheless, using it on this level with the "children" parameter shouldn't lead to this behavior.

In fact, the issue happens even on multiple levels if there are more suite setups on different levels.
That means, if I set the suite variable in the init.robot file to the value "a", then execute "Check Variable" in the init.robot file, the value is "a" (as expected). Then in the "Test Suite Setup" keyword I set the value to "b", but "Check Variable" still returns "a". Then in the test case, I set the value to "c", but "Check Variable" returns this time "b", so always the value which was set "one layer above".

@pekkaklarck
Copy link
Member

I can reproduce the problem. It's due to our bad variable namespace handling. I need to see how it could be fixed.

@pekkaklarck pekkaklarck added this to the v7.0 milestone Dec 19, 2023
@pekkaklarck pekkaklarck self-assigned this Dec 19, 2023
@pekkaklarck pekkaklarck changed the title [BUG] "children" argument in "Set Suite Variable" keyword leads to wrong behavior in suite variable scope Variables set using Set Suite Variable with children=True cannot be properly overwritten Dec 19, 2023
@pekkaklarck
Copy link
Member

Ought to be fixed now and the fix will be in RF 7.0 rc 1 that we plan to release tomorrow. It would be great if you @oetzus could validate the fix in your environment once the release candidate is out. If there still are problems, we can fix them before the final release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants