机器人固件:Buitlin库:设置套件变量:如何将当前测试范围内的变量传递到新的测试范围?

问题描述 投票:0回答:1

Acc.to the documentation

((1)如果当前范围内已经存在一个变量,则可以将该值保留为空,并且新范围内的变量将获取当前范围内的值。

目标是实现语句(1)的示例。

这里是尝试:

(Test 1/2) Use "Set Suite Variable" : Set Locally Scoped Variable As Suite Scoped
       [Documentation]     If a variable already exists within the current scope 
       ...                 (i.e. Test 1/2), the value can be left empty and
       ...                 the variable within the new scope (i.e. Test 2/2) gets 
       ...                 the value within the current scope (i.e Test 1/2)

       ${local_to_suite_scoped} =     Set Test Variable   ${3}
       # intentionally not setting any value to comply with the statement (1)
       Set Suite Variable      ${local_to_suite_scoped} 

(Test 2/2) Use "Set Suite Variable" : Use local_to_suite_scoped in this test
       Variable Should Exist   ${local_to_suite_scoped}
       Should Be Equal         ${local_to_suite_scoped}     ${3}  # fails with None != 3, expected 3 == 3

测试2/2失败,但是为什么呢?陈述(1)是否正确或测试用例是否正确实施?如果测试用例的实现不正确,您能否提供正确的实现?

robotframework built-in
1个回答
0
投票
${local_to_suite_scoped} = Set Test Variable ${3}

Set Test Variable    ${local_to_suite_scoped}    ${3}

http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Set%20Suite%20Variable上查看更多信息

© www.soinside.com 2019 - 2024. All rights reserved.