当前位置:网站首页>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('发短信')
执行
不需要什么参数直接执行就行
边栏推荐
- 使用grid实现左中右布局,中间内容自适应
- Bash shell学习笔记(七)
- 242.有效的字母异位词
- Flutter编译报错 version of NDK matched the requested version 21.0.6113669. Versions available locally: 2
- 菜鸟看源码之LinkedBlockingQueue
- 菜鸟看源码之ArrayList
- Bash shell learning notes (II)
- Constructors, method overloads, object arrays, and static
- Esxi6.5 patch update
- 35. 搜索插入位置
猜你喜欢

The problem of formatting IAR sprintf floating point to 0.0 in UCOS assembly

Many people don't know whether they are looking for Kanban software or Kanban software

Drbl diskless startup + Clonezilla network backup and restore system

2021-08-12 function recursion_ Learn C language with brother Peng
![[dectectron2] follow the official demo](/img/aa/03e46897234c309415b336ac39b7d9.png)
[dectectron2] follow the official demo
![[leetcode daily question 2021/2/18] [detailed explanation] minimum number of turns of 995. K continuous bits](/img/de/62fca587cde95110c2a967ca93eea5.png)
[leetcode daily question 2021/2/18] [detailed explanation] minimum number of turns of 995. K continuous bits
![[leetcode daily question 2021/4/23]368. Maximum divisible subset](/img/0b/32ca862963c842a93f79eaac94fb98.png)
[leetcode daily question 2021/4/23]368. Maximum divisible subset

很多人都不清楚自己找的是Kanban软件还是看板软件

Newbie sees the source code arraydeque

微信公众号消息通知 “errcode“:40164,“errmsg“:“invalid ip
随机推荐
11 handle "self assignment" in operator=
创建EOS账户 Action
软件测试综述之软件测试的背景、实质、软件开发的过程
对面向抽象编程的理解
RT thread learning notes (I) -- configure RT thread development environment
【小程序】onReachBottom 事件为什么不能触发 ?(一秒搞定)
35. 搜索插入位置
回到顶部的几种方案(js)
Bash shell学习笔记(四)
Bash shell学习笔记(五)
解决org.apache.commons.codec.binary.Base64爆红问题
MFC中0x003b66c3 处有未经处理的异常: 0xC000041D: 用户回调期间遇到未经处理的异常
[leetcode daily question 2021/2/14]765. Lovers hold hands
Constructors, method overloads, object arrays, and static
Sql Server 数据库之初学体验
MFC picture control
Kali view IP address
RT thread learning notes (VI) -- start the elmfat file system based on SPI flash (Part 1)
Many people don't know whether they are looking for Kanban software or Kanban software
MultipartFil转为File