python - 有没有办法用多个关键字动态构建机器人框架套件设置?
问题描述
我正在为单元测试构建机器人框架套件和动态测试。我们有一个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
并使用了AND
in ,args
以便可以将多个关键字添加到套件设置中。
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")
推荐阅读
- php - codeigniter helper 未在 linux 中加载,在我的 windows 本地主机中工作正常
- haproxy - 通过 haproxy 路由的请求比直接调用慢很多
- reactjs - 如何在构造函数中将函数分配给状态?
- javascript - 调用与调用函数
- java - 在检索期间保存文件并保留顺序
- swift - 你可以在 Swift 中计算布尔属性吗?
- python - 单线创建列表字典
- php - 在 WooCommerce 中过滤产品类别存档页面
- ios - 如果您使用 Windows 操作系统连接到 Mac 操作系统,如何获取 Xamarin ios App 的 ipa 文件?
- html - SVG 过滤器显示不正确的颜色