自动化测试框架RF---用户关键字

用户关键字:本质上来讲就是封装函数,然后用例可以调用

直接看代码吧,不清楚的可以留言

*** Test Cases ***
case1
    关键字1

case2
    关键字2-带形参  小美女

case3
    关键字3-带缺省值参数     小美女

case4
    关键字4--不定长位置参数      1   2   hello   睡觉吧

case5
    关键字5-不定长关键字参数   a=1     b=2     age=18      name=test


case6
    ${result}   关键字6-返回值
    log to console  ${result}



*** Keywords ***
关键字1
    log to console  执行用例1

关键字2-带形参
    [Arguments]  ${name}
    log to console  my name is ${name}

关键字3-带缺省值参数
    [Arguments]  ${name}    ${age}=${18}
    log to console  现在是晚上十一点钟,你要睡觉吗,${name}
    should be true  18==$age

关键字4--不定长位置参数
    [Arguments]  @{args}
    FOR  ${item}    IN     @{args}
    log to console  ${item}
    END


关键字5-不定长关键字参数
    [Arguments]  &{kwargs}
    FOR  ${item}    IN     &{kwargs}
    log to console  ${item}
    END


关键字6-返回值
    # 如果返回多个值,跟python一样的用法
    ${result}   evaluate    [x for x in range(10)]
    [Return]  ${result}

运行结果:

猜你喜欢

转载自blog.csdn.net/qq_19982677/article/details/108674617