Robotframework Robot FW:内置库:设置套件变量:如何将当前测试范围内的变量传递到新的测试范围?
根据: 1如果当前范围内已存在变量,则该值可以保留为空,并且新范围内的变量将获取当前范围内的值 目标是实现语句1的一个示例 以下是一个尝试:Robotframework Robot FW:内置库:设置套件变量:如何将当前测试范围内的变量传递到新的测试范围?,robotframework,built-in,Robotframework,Built In,根据: 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 ...
(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是否不正确,或者测试用例的实现是否不正确?如果测试用例的实现不正确,您能提供正确的实现吗?像Set Suite Variable一样设置测试变量-关键字要求第一个参数是变量的名称。第二个变量将是该变量的值。所以不是
${local_to_suite_scoped} = Set Test Variable ${3}
做
更多信息请访问
Set Test Variable ${local_to_suite_scoped} ${3}