[英]Is there a way to dynamically build a robot framework suite setup with multiple keywords?
I am building robot framework suites and tests dynamically for unit testing.我正在构建机器人框架套件并动态测试以进行单元测试。 We have a
Global Setup
that applies to all tests at the suite level.我们有一个适用于套件级别的所有测试的
Global Setup
。 However, some sets of tests have additional setup that could also be applied at the suite level.但是,某些测试集具有额外的设置,也可以应用于套件级别。 Is there any built-in way to append more keywords to the suite setup?
是否有任何内置方法可以将更多关键字附加到套件设置中?
I have something like this:我有这样的事情:
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")
I could not find a way to ADD more keywords to the suite setup via the listener approach.我找不到通过侦听器方法向套件设置添加更多关键字的方法。 Below is the best I could muster.
下面是我能收集到的最好的。 Maybe it is obvious, but it also seems like there should be a better way.
也许这是显而易见的,但似乎也应该有更好的方法。
I updated suite.setup.config
to run Run Keywords
and used an AND
in the args
so that I could add multiple keywords to the suite setup.我更新了
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")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.