Robot FW : Buitlin library : Set Suite Variable : 如何将当前测试范围内的变量传递给新的测试范围?
Robot FW : Buitlin library : Set Suite Variable : How to pass the variable within the current test scope to a new test scope?
Acc.to the documentation:
(1) If a variable already exists within the current scope, the value can be left empty and the variable within the new scope gets the value within the current scope.
目标 是实现语句 (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
# 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} # fails with None != 3, expected 3 == 3
测试 2/2 失败,但为什么?陈述 (1) 是错误的还是测试用例实施不正确?如果测试用例实现不正确,能否提供正确的实现?
Set Test Variable
(如 Set Suite Variable
-关键字)期望第一个参数是变量的名称。第二个变量将是变量的值。所以而不是
${local_to_suite_scoped} = Set Test Variable
做
Set Test Variable ${local_to_suite_scoped}
在 http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Set%20Suite%20Variable
查看更多
Acc.to the documentation:
(1) If a variable already exists within the current scope, the value can be left empty and the variable within the new scope gets the value within the current scope.
目标 是实现语句 (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
# 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} # fails with None != 3, expected 3 == 3
测试 2/2 失败,但为什么?陈述 (1) 是错误的还是测试用例实施不正确?如果测试用例实现不正确,能否提供正确的实现?
Set Test Variable
(如 Set Suite Variable
-关键字)期望第一个参数是变量的名称。第二个变量将是变量的值。所以而不是
${local_to_suite_scoped} = Set Test Variable
做
Set Test Variable ${local_to_suite_scoped}
在 http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Set%20Suite%20Variable
查看更多