【问题标题】:Is there a way to configure Robot Framework so the execution is not stopped by a failure有没有办法配置机器人框架,所以执行不会因失败而停止
【发布时间】:2018-10-18 01:38:18
【问题描述】:

我知道 Run Keyword and Continue on Failure / Run Keyword And Ignore Error / Run 关键字和 return status 内置关键字,但我有一组非常广泛的测试用例,不应因任何原因在特定的情况下停止我想知道是否有一个选项可以在默认情况下不让执行在失败时停止,而不必通过这些关键字来管理它并在我的上层关键字中添加与业务无关的语法。

【问题讨论】:

    标签: python testing automated-tests robotframework atdd


    【解决方案1】:

    一般来说,机器人根本无法按照您想要的方式工作。它旨在在关键字失败时退出测试,除非您使用特殊关键字之一显式运行该关键字(例如:run keyword and continue on failure)。

    在一些非常有限的情况下,您可以通过使用为每个测试步骤调用run keyword and continue on failure 的模板来获得此行为。此技术仅在您的测试用例严格由关键字组成且不尝试将关键字结果保存到变量时才有效。

    例如,考虑这个测试:

    *** Test cases ***
    Example
        log   step one
        log   step two
        fail  something went wrong
        fail  something else went wrong
        log   last step
    

    如果您运行上述测试,它将在第一次失败时停止。但是,通过添加使用run keyword and continue on failure 的测试模板,所有步骤将在继续下一个测试之前运行:

    *** Test cases ***
    Example
        [Template]  Run keyword and continue on failure
        log   step one
        log   step two
        fail  something went wrong
        fail  something else went wrong
        log   last step
    

    这是上面测试报告的样子:

    【讨论】:

    • 使用模板的选项符合我的需要,因为我在测试用例的上层只使用关键字。我没想到。我会试试看。谢谢!
    【解决方案2】:

    尽管您在遇到错误情况时应该继续操作感觉有点违反直觉,但鉴于您可能不再控制应用程序。这本身就应该被阻止。不过,话是这么说。

    鉴于您已经熟悉 Run 和 continue 关键字系列,因此没有太多建议和肯定的回答:否。

    唯一的方法是将关键字包装在 Run and Continue 关键字中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-29
      • 2014-02-10
      • 1970-01-01
      • 2014-05-16
      • 1970-01-01
      • 2021-01-14
      • 2020-12-13
      • 1970-01-01
      相关资源
      最近更新 更多