当前位置:网站首页>pytest interface automation testing framework | single/multiple parameters
pytest interface automation testing framework | single/multiple parameters
2022-08-01 07:27:00 【COCOgsta】
Video source: Station B "Upload at risk!pytest interface automation testing framework (basic theory to project actual combat and secondary development) teaching video [software testing]"
Organize the teacher's course content and test notes while studying, and share it with everyone. The infringement will be deleted immediately. Thank you for your support!
Attach the summary post: pytest interface automation testing framework | Summary_COCOgsta's blog-CSDN blog
Function data parameterization
It is convenient for the test function to obtain the test data.
Method:
parametrize(argnames, argvalues, indirect=False, ids=None, scope=None)
Common parameters:
argname: parameter name
- argvalues: the corresponding value of the parameter, the type must be list
- Format when parameter is one: [value]
- When the number of parameters is more than one, the format is: [(param_value1, param_value2, ...), (param_value1, param_value2, ...)]
How to use:
@pytest.mark.parametrize(argnames, argvalues)
If the parameter value is N, the test method will be run N times
Single parameter
import pytest# a parameter is given 2 values, the function will run 2 [email protected]("a", ['aaa', 'bbb'])# The parameters must be consistent with the parameters in parametrizedef test_01(a):print('\n' + a)if __name__ == '__main__':pytest.main(['-s', 'test_single_param.py'])
Multiple parameters
import pytest# a parameter is given 2 values, the function will run 2 [email protected]("a,b", [('zz', '123456'), ('xz', '123456')])# The parameters must be consistent with the parameters in parametrizedef test_01(a, b):print('\n' + a)print('\n' + b)if __name__ == '__main__':pytest.main(['-s', 'test_multi_param.py'])
边栏推荐
- 企业员工人事管理系统(数据库课设)
- 安装SQL Server详细教程
- Generate pictures based on the content of the specified area and share them with a summary
- Image lossless compression software which works: try completely free JPG - C image batch finishing compression reduces weight tools | latest JPG batch dressing tools download
- MVVM项目开发(商品管理系统一)
- pytest接口自动化测试框架 | 跳过模块
- JSON 与 JS 对象的区别
- 请问用flinksql写入数据到clickhouse需要引入什么依赖吗?
- LeetCode240+312+394
- datagrip 报错 “The specified database userpassword combination is rejected...”的解决方法
猜你喜欢
随机推荐
JSON 与 JS 对象的区别
升级为重量级锁,锁重入会导致锁释放?
pytest接口自动化测试框架 | 跳过模块
05-SDRAM: Arbitration
日志导致线程Block的这些坑,你不得不防
对于升级go1.18的goland问题
国内外最顶级的8大plm项目管理系统
my creative day
小程序通过云函数操作数据库【使用get取数据库】
app 自动化 打开app (二)
MVVM project development (commodity management system 1)
好的plm软件有哪些?plm软件排行榜
Explosive 30,000 words, the hardest core丨Mysql knowledge system, complete collection of commands [recommended collection]
gethostbyname \ getaddrinfo 解析域名IP地址不安全的原因
Vim三种模式
pytest接口自动化测试框架 | parametrize叠加使用
并发编程13-JUC之CountDownLatch
Golang:go获取url和表单属性值
JVM:运行时数据区-PC寄存器(程序计数器)
【手撕AHB-APB Bridge】~ AHB地址总线的低两位为什么不用来表示地址呢?