带有 pabot 的机器人框架:是否可以在两个测试中将两个不同的值传递给一个变量 [英] robot framework with pabot : is it possible to pass two different values to a variable in two tests

查看:87
本文介绍了带有 pabot 的机器人框架:是否可以在两个测试中将两个不同的值传递给一个变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我有 file1.robotfile2.robot 并且每个都有 ${var} 作为变量.我可以在命令行中将 2 个不同的值传递给同一个 ${var} 吗?类似 pabot -v var:one:two file1.robot file2.robot 之类的东西,其中 -v var:one:two 将遵循机器人文件的顺序;不是按名称而是按它们在命令行中的引入方式?

Example, I have file1.robot and file2.robotand each has ${var} as the variable. Can I pass 2 different values to this same ${var} in the command line? Something like pabot -v var:one:two file1.robot file2.robot where -v var:one:two would follow the order of the robot files; not by name but by how they were introduced in the command line?

推荐答案

这个解决方案不是您所要求的 100%,但也许您可以让它发挥作用.

This solution is not 100% what you've asked for, but maybe you can make it work.

pabot 自述文件中提到了关于共享变量集的一些内容并为每个正在运行的进程获取集.文档对我来说有点不清楚,但是如果您尝试以下示例,您会亲眼看到.它基本上是变量池,每个进程都可以从中获取一组变量,当它完成时,它可以将这个集合返回到池中.

In pabot readme file is mentioned something about shared set of variables and acquiring set for each running process. The documentation was bit unclear to me, but if you try following example, you'll see for yourself. It's basically pool of variables and each process can get set of variables from it and when it's done with it, it can return this set back to the pool.

创建您的值集valueset.dat

[Set1]
USERNAME=user1
PASSWORD=password1

[Set2]
USERNAME=user2
PASSWORD=password2

创建 suite1.robotsuite2.robot.我创建了 2 个完全相同的套件.我只是想尝试并行运行 2 个套件.

create suite1.robot and suite2.robot. I've created 2 suites that are exactly the same. I just wanted to try to run 2 suites in parallel.

*** Settings ***
Library    pabot.PabotLib

*** Test Cases ***
Foobar
    ${valuesetname}=    Acquire Value Set
    Log    ${valuesetname}
    ${username}=     Get Value From Set   username
    Log    ${username}
    # Release Value Set

然后运行命令pabot --pabotlib --resourcefile valueset.dat tests.如果您查看 html 报告,您会看到一个套件使用了 set1,另一个使用了 set2.

And then run command pabot --pabotlib --resourcefile valueset.dat tests. If you check html report, you'll see that one suite used set1 and other used set2.

希望这会有所帮助.
干杯!

Hope this helps.
Cheers!

这篇关于带有 pabot 的机器人框架:是否可以在两个测试中将两个不同的值传递给一个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆