Robot Framework 在 If 条件下的多条语句
Robot Framework Multiple Statements in If Condition
我是 Robot Framework 的新手,正在尝试弄清楚如何让多个语句与 If 条件相关联。
基本前置代码对数组WORDS中的条目进行计数,并将值赋给长度。
${length}= Get length ${WORDS}
接下来我想对数组的大小做一个简单的检查(应该有 10 个项目)。
${status}= Set Variable If ${length} == 10 TRUE FALSE
现在我想记录结果并通过或未通过测试用例。
Run Keyword If $status == "TRUE"
... Log ${status}
... ELSE
... Log ${status}
Run Keyword If $status != "TRUE"
... FAIL Values do not match
我想结合 ELSE + 记录状态 + 测试用例失败,但似乎无法弄清楚。在 C 编程中,我会简单地将 { } 之间的语句括起来就可以了。
在 Robot Framework 中,我已经尝试 'Run keywords' 但没有成功。
... ELSE Run keywords
... Log ${status}
... FAIL Values Do Not Match
我希望有办法做到这一点。感谢任何输入。
您可以使用 log 和 fail 关键字创建关键字并将状态作为参数传递,然后只需在 ELSE 语句之后使用此关键字。
或像您一样使用 运行 关键字,但在 FAIL 之前添加 AND 语句(在此处阅读更多信息:http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Run%20Keywords)
或考虑将 ${status} 添加到失败消息:失败值不匹配。状态:${status}
使用"Run keywords" 是正确的解决方案。但是,为了 运行 多个关键字,您必须使用文字 AND
:
分隔关键字
... ELSE run keywords
... log ${status}
... AND FAIL Values Do Not Match
Set Test Variable ${temp} rxu
Run Keyword if '${temp}'=='rxu'
... Run Keywords
... Log To Console this is one
... Log To Console This is two
... ELSE Run Keyword Log To Console another block
我是 Robot Framework 的新手,正在尝试弄清楚如何让多个语句与 If 条件相关联。
基本前置代码对数组WORDS中的条目进行计数,并将值赋给长度。
${length}= Get length ${WORDS}
接下来我想对数组的大小做一个简单的检查(应该有 10 个项目)。
${status}= Set Variable If ${length} == 10 TRUE FALSE
现在我想记录结果并通过或未通过测试用例。
Run Keyword If $status == "TRUE"
... Log ${status}
... ELSE
... Log ${status}
Run Keyword If $status != "TRUE"
... FAIL Values do not match
我想结合 ELSE + 记录状态 + 测试用例失败,但似乎无法弄清楚。在 C 编程中,我会简单地将 { } 之间的语句括起来就可以了。
在 Robot Framework 中,我已经尝试 'Run keywords' 但没有成功。
... ELSE Run keywords
... Log ${status}
... FAIL Values Do Not Match
我希望有办法做到这一点。感谢任何输入。
您可以使用 log 和 fail 关键字创建关键字并将状态作为参数传递,然后只需在 ELSE 语句之后使用此关键字。
或像您一样使用 运行 关键字,但在 FAIL 之前添加 AND 语句(在此处阅读更多信息:http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Run%20Keywords)
或考虑将 ${status} 添加到失败消息:失败值不匹配。状态:${status}
使用"Run keywords" 是正确的解决方案。但是,为了 运行 多个关键字,您必须使用文字 AND
:
... ELSE run keywords
... log ${status}
... AND FAIL Values Do Not Match
Set Test Variable ${temp} rxu
Run Keyword if '${temp}'=='rxu'
... Run Keywords
... Log To Console this is one
... Log To Console This is two
... ELSE Run Keyword Log To Console another block