【问题标题】:What's wrong with my robot framework teardown?我的机器人框架拆解出了什么问题?
【发布时间】:2015-10-12 05:17:43
【问题描述】:

我是使用机器人框架的新手,我正在努力让我的拆解工作。 目前看起来像:

[Teardown]  run keyword if any tests failed  KeyFail

当我使用这样的代码运行程序时,我收到错误消息:Keyword 'Run Keyword If Any Tests Failed' can only be used in suite teardown.

我可以更改它,以便将它放在它自己的测试用例中,但是我得到错误:测试用例不包含关键字。

请告诉我我做错了什么。将不胜感激。谢谢。

编辑:

***Keywords***
Generation
    (Some stuff)
KeyFail
    log to console  Error report being sent.


***Test Cases***
Requires successful generation of file
    Generation
Teardown Case
    [Teardown]  run keyword if any tests failed  KeyFail

编辑:以及如何解决这个问题。谢谢

【问题讨论】:

  • 更多信息会有所帮助。
  • 错误信息告诉你到底是什么问题。

标签: robotframework teardown


【解决方案1】:

看起来您已经在 测试用例 拆解而不是测试 suite teardown 中定义了它。您可以将其更改为使用 Test 拆解。

编辑:这里有两个解决方案:
1. 将您的关键字更改为 TEST 特定的 Run Keyword If Test Failed,它适用于最后执行的测试,并且只能在测试拆解中使用。
2.第二种是使用Suite Setups/teardowns。这些适用于您运行的所有测试用例。像这样:

***Settings***
Suite Setup    Your Test Setup Keyword
Suite Teardown  run keyword if any tests failed  KeyFail

***Keywords***
Generation
    (Some stuff)
KeyFail
    log to console  Error report being sent.


***Test Cases***
Requires successful generation of file
    Generation
Teardown Case
    Stuff to do
    # teardown is automatic, and does not need to be called.

【讨论】:

    猜你喜欢
    • 2017-04-23
    • 2013-01-26
    • 1970-01-01
    • 1970-01-01
    • 2019-06-06
    • 2020-10-22
    • 1970-01-01
    • 2017-04-18
    • 1970-01-01
    相关资源
    最近更新 更多