簡體   English   中英

有沒有辦法使用多個關鍵字動態構建機器人框架套件設置?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM