【问题标题】:Is there a way to dynamically build a robot framework suite setup with multiple keywords?有没有办法用多个关键字动态构建机器人框架套件设置?
【发布时间】:2021-12-03 02:25:10
【问题描述】:

我正在为单元测试构建机器人框架套件和动态测试。我们有一个Global Setup,它适用于套件级别的所有测试。但是,某些测试集具有额外的设置,也可以在套件级别应用。是否有任何内置方法可以将更多关键字附加到套件设置中?

我有这样的事情:

from robot.api import TestSuite

suite = TestSuite("Foo")
suite.setup.config(name="Global Setup")
# i want to then append to suite.setup based on some condition
if bar:
    # append more keywords to suite.setup
...
# add tests etc
...
result = suite.run(output="out.xml", loglevel="TRACE")

【问题讨论】:

标签: python robotframework


【解决方案1】:

我找不到通过侦听器方法向套件设置添加更多关键字的方法。以下是我能召集的最好的。也许这很明显,但似乎应该有更好的方法。

我更新了suite.setup.config 以运行Run Keywords,并在args 中使用了AND,这样我就可以在套件设置中添加多个关键字。

from robot.api import TestSuite

suite = TestSuite("Foo")
suite.setup.config(name="Global Setup")
# i want to then append to suite.setup based on some condition
if bar:
    # append more keywords to suite.setup
    suite.setup.config(name="Run Keywords", args=["Global Setup", "AND", "Other Setup"...])
...
# add tests etc
...
result = suite.run(output="out.xml", loglevel="TRACE")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-07
    • 2022-01-06
    • 2020-09-23
    • 2014-05-16
    • 2020-09-25
    • 1970-01-01
    • 2020-06-14
    • 2017-12-07
    相关资源
    最近更新 更多