当前位置:网站首页>Pytest数据参数化&数据驱动
Pytest数据参数化&数据驱动
2022-06-22 06:16:00 【三三三思】
参数化使用:
@pytest.mark.parametrize(argnames,argvalues)
argnames:要参数化的变量,string(逗号分隔),list,tuple
argvalues:参数化的值,list,list[tuple]
使用string:@pytest.mark.parametrize(‘a,b’,[(10,20),(30,40)])
使用list:@pytest.mark.parametrize([‘a’,‘b’],[(10,20),(30,40)])
使用tuple:@pytest.mark.parametrize((‘a’,‘b’),[(10,20),(30,40)])
使用yaml数据参数化:
yaml实现list:
list
- 10
- 20
- 30
yaml实现字典:
dict
by:id
locator:name
action:click
yaml进行嵌套:
-
- by:id
- locator:name
- action:click
加载yaml文件:yaml.safe_load(open(“./test.yaml”))
数据驱动
简介
数据驱动就是数据的改变从而驱动自动化测试的执行,最终引起测试结果的改变。简单来说,就是参数化的应用。数据量小的测试用例可以使用代码的参数化来实现数据驱动,数据量大的情况下建议使用一种结构化的文件(例如yaml,json)来对数据进行存储,然后在测试用例中读取到这些数据。
应用场景
App、web、接口自动化测试
1.测试步骤的数据驱动
2.测试数据的数据驱动
3.配置的数据驱动
边栏推荐
- Geoswath plus technology and data acquisition and processing
- R语言观察日志(part24)--writexl包
- 单细胞文献学习(part2)--stPlus: a reference-based method for the accurate enhancement of ST
- 生产者和消费者问题
- Vulnérabilité à l'injection SQL (XIII) injection base64
- StopWatch的使用
- Bat common batch script record
- Performance optimization best practices for reducing Game Size
- 线程池的七大参数及自定义线程池
- Ptrade trading program code - from zero to firm offer 19
猜你喜欢

W800芯片平台进入OpenHarmony主干

Discrete PID control based on MATLAB

Surfer grid file clipping

从入门到精通之专家系统CLIPS(一)CLIPS初识与概述

Callable

雷达导引头伺服系统的建模与仿真

生产者和消费者问题

生信文献学习(part1)--PRECISE: a ... approach to transfer predictors of drug response from pre-clinical ...
![tab[i = (n - 1) & hash] 的详细解读](/img/be/3e84b3e8406833c2a235494f1a035f.png)
tab[i = (n - 1) & hash] 的详细解读

No business series 7: removing spots from old photos
随机推荐
单细胞论文记录(part6)--SpaGE: Spatial Gene Enhancement using scRNA-seq
生产者和消费者问题
Expert system clips from introduction to mastery (I) introduction and overview of clips
The difference between drop, truncate and delete
【NAND文件系统】UBI介绍
Subqueries in sqlserver
878. 第 N 个神奇数字 数学+二分
GeoSwath plus 技术和数据采集处理
Swagger common annotation summary
关于jinja2 宏定义的小问题
h = key.hashCode()) ^ (h >>> 16) 详细解读以及为什么要将hashCode值右移16位并且与原来的hashCode值进行异或操作
SQL 注入漏洞(十三)base64注入
clickhouse对比两台机器数据
Ptrade trading program code - from zero to firm offer 19
Single cell thesis record (Part12) -- unsupervised spatial embedded deep representation of spatial transcriptomics
关于MNIST线性模型矩阵顺序问题
Case analysis of terminal data leakage prevention
Single cell paper records (Part8) -- cell2location maps fine grained cell types in spatial transcriptomics
Oracle之trim,ltrim,rtrim三个函数的用法
Callable