2

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

[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
    [Teardown]  run keyword if any tests failed  KeyFail

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

4

1 回答 1

4

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

编辑:这里有两种解决方案:
1. 将您的关键字更改为特定于 TEST 的关键字,如果测试失败则运行关键字,它适用于最后执行的测试,并且只能用于测试拆解。
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.
于 2015-07-22T11:18:51.963 回答