Robot Framework-[Return]行之后的关键字也正在执行

时间:2019-06-25 11:17:33

标签: robotframework

正在执行[Return]语句之后编写的指令集。 Robot Framework应该出现错误,或者不应考虑在[Return]关键字之后编写的关键字。如果我错过了什么,请给出解释。

Settings

Variables

Keywords
Custom Keyword
[Return] hyyyy
Return From Keyword hyyyy2222

Test Cases
Test1
${var_rt_ky2}= Custom Keyword
Log To Console ${var_rt_ky2}

输出: hyyyy2222

在其他情况下

Settings

Variables

Keywords
Custom Keyword
Return From Keyword hyyyy2222
[Return] hyyyy

Test Cases
Test1
${var_rt_ky2}= Custom Keyword
Log To Console ${var_rt_ky2}

输出: hyyyy

1 个答案:

答案 0 :(得分:2)

这是设计机器人工作方式的方式。 [return]仅定义返回值,它不会导致关键字在调用时返回。

如果要从函数中显式返回,则需要使用内置库中的关键字之一(例如Return from keywordReturn from keyword if等)