[英]Can I put defined robot keywords under Suite SetUp/ Test Setup in Robot Framework
[英]Is there a way to dynamically build a robot framework suite setup with multiple keywords?
我正在构建机器人框架套件并动态测试以进行单元测试。 我们有一个适用于套件级别的所有测试的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")
我找不到通过侦听器方法向套件设置添加更多关键字的方法。 下面是我能收集到的最好的。 也许这是显而易见的,但似乎也应该有更好的方法。
我更新了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.