可以使用命令行参数调用 Robot Framework 测试套件吗? [英] Can Robot Framework test suites be called with command-line parameters?
问题描述
我们正在 git 环境中开发/发布机器人测试,其中公共(已发布)git 与开发 git 的设置略有不同(由于个人工作空间(开发)与全局环境设置).
We are developing / publishing robot-tests in a git environment, where the public (published) git has slightly different settings then the development git (due to personal work-space (development) vs global environment settings).
因为这是我们的机器人关键字之一,对于开发和公众来说是不同的.目前,我们通过为开发 git 注释掉关键字的 .robot 实现中的 1 行并为公共 git 注释掉另一行来管理此问题,但这很容易出错.
Because of this one of our robot keywords is different for development and public. Currently we manage this by commenting out 1 line in the keyword's .robot implementation for the development git and another one for the public git, but this is error prone.
是否可以使用一些额外的命令行选项调用 pybot,这些选项将通过 .robot 文件传递到实现最终关键字的 python 文件,以便我们可以将 .robot 文件中的 2 行移动到 python 实现并根据给定的命令行选项决定使用哪个?
Is it possible to call pybot with some extra command-line options which will be passed on via the .robot files to the python files implementing the final keywords so we can move the 2 lines from the .robot file to the python implementation and decide which to use based on the given command-line option?
推荐答案
检查 在命令行中设置变量 用户指南的一部分.使用 --variable MYVAR:value
命令行参数,您可以创建全局变量.
Check the Setting variables in command line part of the user guide. With the --variable MYVAR:value
command line argument you can create global variables.
例如:
*** Variables ***
${VAR} localenv # this is not necessarily needed, it is used to set default value
*** Test Case ***
Test
IF '${VAR}' == 'localenv'
Log Do this
ELSE IF '${VAR}' == 'globalenv'
Log Do that
END
本地运行
robot test.robot
全球:
robot --variable VAR:globalenv test.robot
这篇关于可以使用命令行参数调用 Robot Framework 测试套件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!