当前位置:网站首页>pytest pytest.ini配置 用例分组 用例跳过
pytest pytest.ini配置 用例分组 用例跳过
2022-07-26 10:50:00 【亚索不会吹风】
pytest pytest.ini配置 用例分组 用例跳过
一.pytest.ini配置
1.文件位置,根目录下
addopts = -vs 配置默认携带的参数
testpaths = ./basics 配置默认执行用例的目录
配置用例分组的便签名
markers =
smoke:冒烟用例
huigui:回归用例
2.文件格式编码
使用工具变成ANSI编码,不然无法读取配置文件

二.用例分组
代码
@pytest.mark.run(order=1)
这条只属于冒烟用例
@pytest.mark.smoke
def test1():
print('登录')
@pytest.mark.run(order=4)
def test4():
print('取件')
@pytest.mark.skip(reason="说明跳过原因")
def test_skip():
print("测试跳过这条用例")
这条被设置为2个分组,属于冒烟和回归
@pytest.mark.run(order=2)
@pytest.mark.huigui
@pytest.mark.smoke
def test2():
print('存件')
age=17
@pytest.mark.run(order=3)
这条只属于冒烟用例
@pytest.mark.huigui
@pytest.mark.skipif(age<18,reason="未成年人不需要发短信")
def test3():
print('发短信')
执行
1.只执行冒烟
pytest.main([r'D:\python新代码集\pytest_study\basics\test_execution_sequence.py','-m smoke'])

2.只执行回归
pytest.main([r'D:\python新代码集\pytest_study\basics\test_execution_sequence.py','-m huigui'])

3.执行冒烟和回归的交集
pytest.main([r'D:\python新代码集\pytest_study\basics\test_execution_sequence.py','-m huigui and smoke'])

4.执行冒烟和回归的并集
pytest.main([r'D:\python新代码集\pytest_study\basics\test_execution_sequence.py','-m huigui or smoke'])

三.用例跳过
知识点
无条件跳过加上跳过原因
@pytest.mark.skip(reason="说明跳过原因")
def test_skip():
print("测试跳过这条用例")
有条件跳过加上判断条件,满足条件就跳过
age=17
@pytest.mark.run(order=3)
@pytest.mark.huigui
@pytest.mark.skipif(age<18,reason="未成年人不需要发短信")
def test3():
print('发短信')
代码
@pytest.mark.run(order=1)
@pytest.mark.smoke
def test1():
print('登录')
@pytest.mark.run(order=4)
def test4():
print('取件')
@pytest.mark.skip(reason="说明跳过原因")
def test_skip():
print("测试跳过这条用例")
@pytest.mark.run(order=2)
@pytest.mark.huigui
@pytest.mark.smoke
def test2():
print('存件')
age=17
@pytest.mark.run(order=3)
@pytest.mark.huigui
@pytest.mark.skipif(age<18,reason="未成年人不需要发短信")
def test3():
print('发短信')
执行
不需要什么参数直接执行就行
边栏推荐
- During the interview, how did the interviewer evaluate the level of rust engineers?
- C language pengge 20210812c language function
- Sword finger offer (53): a string representing a numeric value
- 菜鸟看源码之HashTable
- 访问权限——private,public,protected
- Wechat official account development obtains openid times error 40029 invalid code solution
- Anaconda is used on vscode (the environment has been configured)
- Capture ZABBIX performance monitoring chart with selenium
- [leetcode daily question 2021/2/18] [detailed explanation] minimum number of turns of 995. K continuous bits
- 使用Selenium抓取zabbix性能监控图
猜你喜欢

菜鸟看源码之ArrayDeque

@NotBlank、@NotNull 、@NotEmpty 区别和使用

企鹅龙(DRBL)无盘启动+再生龙(clonezilla)网络备份与还原系统

35. Search the insertion position
![Error[pe147]: declaration is incompatible with 'error problem](/img/4f/57145d78f4dc1fe84d2f271dd9d82f.png)
Error[pe147]: declaration is incompatible with 'error problem

软件测试综述之软件测试的背景、实质、软件开发的过程

ESXi6.5补丁更新

使用Selenium抓取zabbix性能监控图

35. 搜索插入位置

0x00007ffd977c04a8 (qt5sqld.dll) (in a.exe): 0xc0000005: an access violation occurred when reading position 0x0000000000000010
随机推荐
Bash shell学习笔记(五)
Stringing of macro parameters and connection of macro parameters in C language
RT thread learning notes (V) -- edit, download and debug programs
SQL Server 之Sql语句创建数据库
解决:无法加载文件 C:\Users\user\AppData\Roaming\npm\npx.ps1,因为在此系统上禁止运行脚本 。
Error[pe147]: declaration is incompatible with 'error problem
Minesweeping Pro version 2021-08-19
display-inline+calc实现左中右布局,中间自适应
The assignment of member pointer defined in C structure and the use of structure pointer as member function parameter
RT thread learning notes (VII) -- open the elmfat file system based on SPI flash (middle)
[leetcode daily question 2021/8/31] 1109. Flight reservation statistics [medium] differential array
Fragment 懒加载
0x00007ffd977c04a8 (qt5sqld.dll) (in a.exe): 0xc0000005: an access violation occurred when reading position 0x0000000000000010
使用float实现左中右布局,中间内容自适应
ESXi6.5补丁更新
Disable usbjatg in Altium Designer
创建EOS账户 Action
router.push(),router.repalce(),router.go()使用
Flutter jni混淆 引入.so文件release包闪退
13 managing resources by objects