【问题标题】:should be true keyword in robot framework应该是机器人框架中的 true 关键字
【发布时间】:2020-12-08 03:26:24
【问题描述】:

想要使用 should be true 关键字验证 10 个参数。

should be true    ${M1}==${M2}==${M3}==${M4}==${M5}==${M6}==${M7}==${M8}==${M9}==${M10}   PROFSU_LC_RES_START_DEINIT_PersDataAndFS is ${M1}
        ...  \nFSLC fs_lc_priv_deinit_fat32 : ### Unmount second Reliance Edge ..Data-resrc-rw is ${M2}\nFSLC fs_lc_priv_deinit_fat32 : ### Unmount third Reliance Edge partition Logistic ..Data-resrc-rw2  is ${M3}
        ...  \nPROFSU_PERS_EMMC_UNMOUNTED is ${M4}
        ...  \nPROFSU_LC_RES_END_DEINIT_PersDataAndFS is ${M5}\nPROFSU_LC_RES_START_INIT_PersDataAndFS is ${M6}
        ...  \nFSLC fs_lc_priv_init_redfs2 : .* ..Data-resrc-rw is ${M7}\nFSLC fs_lc_priv_init_redfs2 : .* ..Data-resrc-rw2 is ${M8}
        ...  \nPROFSU_PERS_EMMC_MOUNTED is ${M9}\nPROFSU_LC_RES_END_INIT_PersDataAndFS is ${M10}

这是正确的方法吗??

我在控制台中得到的结果是“BuiltIn.Should Be True' 预期 1 到 2 个参数,得到 8 个”

【问题讨论】:

  • “应该为真”通常将一个参数作为条件,例如'${STATUS}'=='PASS' 和消息的可选参数。我不明白你从代码中到底在做什么,但也许你可以分别为每个语句做“应该是真的”
  • 感谢@MatthewKing 的回复
  • 感谢@MatthewKing 的回复。我实际上尝试了带有多个参数的应该为真条件:应该为真 Condition1==Condition2 第一个条件是 ${Condition1}\n 第二个条件是 ${Condition2}

标签: robotframework


【解决方案1】:

我尝试了您的示例并将 2 分配给参数。代码运行没有错误。所以你的方法似乎是正确的

Set Test Variable    ${M1}    ${2}
Set Test Variable    ${M2}    ${2}
Set Test Variable    ${M3}    ${2}
Set Test Variable    ${M4}    ${2}
Set Test Variable    ${M5}    ${2}
Set Test Variable    ${M6}    ${2}
Set Test Variable    ${M7}    ${2}
Set Test Variable    ${M8}    ${2}
Set Test Variable    ${M9}    ${2}
Set Test Variable    ${M10}    ${2}
Should Be True    ${M1}==${M2}==${M3}==${M4}==${M5}==${M6}==${M7}==${M8}==${M9}==${M10} 

我怀疑问题出在你的论点上。您可以尝试在 For 循环中验证您的参数,您可以使用关键字 应该等于应该等于字符串等,具体取决于您的参数

    @{arguments}=    Create List
    Append To List    ${arguments}   ${M1}    ${M2}    ${M3}    ${M4}    ${M5}    ${M6}    ${M7}    ${M8}    ${M9}    ${M10}
    FOR    ${arg}    IN    @{arguments}
        Should Be Equal    ${M1}    ${arg}
    END 

【讨论】:

    猜你喜欢
    • 2013-11-08
    • 2020-11-06
    • 2015-10-14
    • 2019-06-11
    • 2017-12-19
    • 2018-02-25
    • 1970-01-01
    • 2021-08-15
    • 2015-11-07
    相关资源
    最近更新 更多