当前位置:网站首页>RobotFramework中setUp的小技巧
RobotFramework中setUp的小技巧
2022-06-22 12:27:00 【点点寒彬】
背景
使用RobotFramework进行测试的时候,经常会需要写一些准备数据的脚本,比如我现在的的脚本框架下,把所有的变量和项目配置都放在服务器上,那么我在执行用例的时候,就必须要去读取这些配置,但是在每个用例都要写一遍这个读取配置的代码,显得很繁琐,偶然的尝试,发现了这个小技巧。
往常的做法
正常来说,我们如果要拿到这些配置,必须要执行获取配置的关键字,然后拿到这个关键字的返回值,然后才能执行后续的步骤,比如如下代码:
*** Keywords ***
get config
log 开始获取配置
[Return] config
*** Test Cases ***
test
${rst} get config
log ${rst}
但是这样做会非常麻烦,每个用例在跑的时候,都必须要调用这个关键字,RobotFramework提供了setUp的方法,但是这个方法是在每个用例开始的时候执行,用来清理环境的,比如用例执行的前置准备,我们的问题是要拿到系统配置的值。在setUp执行的时候,下方的用例,没有地方可以拿到值。
小技巧
其实setUp也是可以拿到值,只是需要做一个简单的动作。如下面的代码:
*** Settings ***
Test Setup get config
*** Keywords ***
get config
log 边栏推荐
- gradle笔记
- docker安装postgresql
- Lao Wang said that the sixth issue of the series: PHP programmers should build their own self-confidence
- Isn't the execution process of ODPs SQL executed from top to bottom
- 巨杉数据库受邀出席鲲鹏开发者年度盛会2022,共建国产化数字底座
- leetcode 1130. 叶值的最小代价生成树
- Tianyi cloud digital government smart data center has passed the certification
- access_ How to deal with token failure after less than two hours
- Tis tutorial 03 export
- Fluentd is easy to get started. Combined with the rainbow plug-in market, log collection is faster
猜你喜欢

Pycharm shell script cannot be run

Fluentd is easy to get started. Combined with the rainbow plug-in market, log collection is faster

257. Binary Tree Paths

310. Minimum Height Trees

leetcode 968.监控二叉树

46. Permutations

信创之下:国产数据库群星闪耀时

MySQL_创建和管理表

MySQL_ Addition, deletion and modification of data processing

SAP 系统License查看申请及导入
随机推荐
Redis
leetcode 834. 树中距离之和
Parallels Desktop 17.1.4pd virtual machine
268. Missing Number
[MySQL] the difference between where and having
0007 reverse integer
帝云CMS升级PHP8注意事项
信创之下:国产数据库群星闪耀时
mysql笔记
vs code
The solution of VPC network automatic configuration based on terraform
Wisdom age voice +php
338. Counting Bits
Final of the 12th Blue Bridge Cup embedded design and development project
AcWing第52场周赛
这不会又是一个Go的BUG吧?
胡润研究院首发中国元宇宙潜力企业榜,巨杉数据库入选未来之星企业
Making rectangular border according to metric system through PostGIS
Set up your own website (5)
Jushan database won two honors of China's information innovation industry in 2022 by AI media consulting