Robotframework—是否有一种方法可以使用';不应在';如果失败了,继续吗?

Robotframework—是否有一种方法可以使用';不应在';如果失败了,继续吗?,robotframework,built-in,Robotframework,Built In,我正在从命令生成一个输出 在继续之前,我想检查一下潜在的4个错误 范例 不应包含${output}error1 msg=您有错误1 不应包含${output}error2 msg=您有错误2 不应包含${output}error3 msg=您有错误3 不应包含${output}error4 msg=您有错误4 当前,当error1与true匹配时,函数失败并中止,也称为致命错误 我希望它继续运行,即使遇到错误1,也可能出现错误3或更多 a、 k.a我希望它“失败”而不是“致命错误” 有没有办法做

我正在从命令生成一个输出 在继续之前,我想检查一下潜在的4个错误

范例

不应包含${output}error1 msg=您有错误1

不应包含${output}error2 msg=您有错误2

不应包含${output}error3 msg=您有错误3

不应包含${output}error4 msg=您有错误4

当前,当error1与true匹配时,函数失败并中止,也称为致命错误 我希望它继续运行,即使遇到错误1,也可能出现错误3或更多 a、 k.a我希望它“失败”而不是“致命错误”


有没有办法做到这一点?/也许可以使用其他方法?

这些关键字中的一个应该是您所需要的:

例1

Run Keyword And Continue On Failure  should not contain   ${output}   error1 msg=you have error 1
例2

${status}  Run Keyword And Return Status  should not contain   ${output}   error1 msg=you have error 1

您有两个选择:

  • Run关键字和returnstatus
    -将返回状态(PASS/FAIL布尔值),但也会忽略错误
  • Run关键字和Ignore Error
    -将为您提供状态('PASS'/'FAIL'字符串)和错误值,并忽略它
  • 您可以在此处找到示例源:

    *** Keyword ***
    Demonstrate Run Keyword and Return Status VS Ignore Error
    
        ${some_text}=   Set Variable   What does the fox say?
    
        ${status}=  Run Keyword And Return Status  Should Not Contain   ${some_text}   fox
        Run Keyword If  not ${status}   Log    \nReturned an error   console=yes
        # Outputs `Returned an Error`
    
    
        # You can also get the error along with the status by using `Run Keywork and Ignore Error`
        ${status}  ${value}=  Run Keyword And Ignore Error  Should Not Contain   ${some_text}   fox
        Log     ${status}    console=yes  # Outputs `FAIL`
        Log     ${value}    console=yes   # Outputs `'What does the fox say?' contains 'fox'`
    
        ${status}  ${value}=  Run Keyword And Ignore Error  Should Not Contain   ${some_text}   fox     msg=Custom Error
        Log     ${status}    console=yes  # Outputs `FAIL`
        Log     ${value}    console=yes   # Outputs `Custom Error: 'What does the fox say?' contains 'fox'`