【问题标题】:Multiple Logs messages in Test测试中的多个日志消息
【发布时间】:2020-08-26 18:50:16
【问题描述】:

我有一个如下脚本:

[CCO-XXXXX_4] 
         [Tags]    TEST_CCO-XXXXX 
         Run Keyword And Continue On Failure        Run Test      General                test.out         testProfile          mode.out 
         Run Keyword And Continue On Failure        Run Test      General                test.out         testProfile          mode.out 

想法是运行 2 个具有不同参数的测试用例:

Run Test
    [Documentation]    Run the suite
    [Arguments]       ${type}     ${profile}     ${file}    ${test}
    When suite config is updated 
    Then publish test status

Then publish test status
    Set Test Message     ${LogStr}

Stop Test  
    [Documentation]    Stop Execution of suite
    [Arguments]       ${FIALUREMSG}        
    Log To Console    ${FIALUREMSG}
    Fail        ${FIALUREMSG}

问题出在报告中 - 当两次运行的测试都失败时,report 消息中有 2 条单独的单独消息:“This is stop called”

但是当它通过时,只有一个消息日志可用 - 因为上述两个测试用例有两次运行,所以每个单独的测试不可能有与测试相关的消息:[例如“你好,这是一个例子”应该记录两次?]

【问题讨论】:

    标签: robotframework


    【解决方案1】:

    您的问题是 Set Test Message 在每次迭代中都会覆盖较早的内容。要解决此问题,您应该使用此关键字的append 参数。例如:

    Set Test Message    is continued.   append=yes
    

    文档中的相关部分:

    如果可选的附加参数被赋予一个真值(请参阅布尔参数),则通过用空格连接消息,将给定的消息添加到可能的较早消息之后。

    【讨论】:

    • 谢谢它的工作,但它在同一行 - 有没有办法也可以用新行记录?
    • @Programmer 我建议在您的消息末尾添加\n,因为分隔符不能被覆盖。例如:Set Test Message ${LogStr}\n
    猜你喜欢
    • 1970-01-01
    • 2018-12-17
    • 2013-01-19
    • 2015-09-12
    • 1970-01-01
    • 1970-01-01
    • 2015-01-06
    • 2023-02-11
    • 2013-08-31
    相关资源
    最近更新 更多