我的机器人框架拆解出了什么问题?

What's wrong with my robot framework teardown?

我刚开始使用机器人框架,我正在努力让我的拆解工作正常进行。 目前看起来像:

[Teardown]  run keyword if any tests failed  KeyFail

当我 运行 使用这样的代码的程序时,我得到错误:关键字 'Run Keyword If Any Tests Failed' 只能在套件拆解中使用。

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

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

编辑:

***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

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

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

编辑:这里有两个解决方案:
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.