当前位置:网站首页>pytest pytest. Ini configuration case grouping case skipping
pytest pytest. Ini configuration case grouping case skipping
2022-07-26 10:55:00 【Yasso won't blow】
pytest pytest.ini To configure Use case grouping Use case skipping
One .pytest.ini To configure
1. file location , The root directory
addopts = -vs Configure the parameters carried by default
testpaths = ./basics Configure the directory of default execution cases
Configure the signature of the use case group
markers =
smoke: Smoke use case
huigui: Regression use cases
2. File format coding
Use tools to become ANSI code , Otherwise, the configuration file cannot be read 

Two . Use case grouping
Code
@pytest.mark.run(order=1)
This only belongs to smoking use case
@pytest.mark.smoke
def test1():
print(' Sign in ')
@pytest.mark.run(order=4)
def test4():
print(' Pick up ')
@pytest.mark.skip(reason=" Explain the reason for skipping ")
def test_skip():
print(" The test skips this use case ")
This is set to 2 Groups , It belongs to smoking and returning
@pytest.mark.run(order=2)
@pytest.mark.huigui
@pytest.mark.smoke
def test2():
print(' File ')
age=17
@pytest.mark.run(order=3)
This only belongs to smoking use case
@pytest.mark.huigui
@pytest.mark.skipif(age<18,reason=" Minors don't need to send text messages ")
def test3():
print(' texting ')
perform
1. Only perform smoking
pytest.main([r'D:\python New code set \pytest_study\basics\test_execution_sequence.py','-m smoke'])

2. Execute regression only
pytest.main([r'D:\python New code set \pytest_study\basics\test_execution_sequence.py','-m huigui'])

3. Perform the intersection of smoking and regression
pytest.main([r'D:\python New code set \pytest_study\basics\test_execution_sequence.py','-m huigui and smoke'])

4. Perform the union of smoke and regression
pytest.main([r'D:\python New code set \pytest_study\basics\test_execution_sequence.py','-m huigui or smoke'])

3、 ... and . Use case skipping
Knowledge point
Unconditional skip plus skip reason
@pytest.mark.skip(reason=" Explain the reason for skipping ")
def test_skip():
print(" The test skips this use case ")
Conditional skip plus judgment , If the conditions are met, skip
age=17
@pytest.mark.run(order=3)
@pytest.mark.huigui
@pytest.mark.skipif(age<18,reason=" Minors don't need to send text messages ")
def test3():
print(' texting ')
Code
@pytest.mark.run(order=1)
@pytest.mark.smoke
def test1():
print(' Sign in ')
@pytest.mark.run(order=4)
def test4():
print(' Pick up ')
@pytest.mark.skip(reason=" Explain the reason for skipping ")
def test_skip():
print(" The test skips this use case ")
@pytest.mark.run(order=2)
@pytest.mark.huigui
@pytest.mark.smoke
def test2():
print(' File ')
age=17
@pytest.mark.run(order=3)
@pytest.mark.huigui
@pytest.mark.skipif(age<18,reason=" Minors don't need to send text messages ")
def test3():
print(' texting ')
perform
You don't need any parameters to execute directly 
边栏推荐
- MySQL quicklearn-2021-09-01
- Stringing of macro parameters and connection of macro parameters in C language
- 349. 两个数组的交集
- pytest 前后置方法
- WinPcap packet capturing function pcap_ Loop (), stop the problem
- 0x00007ffd977c04a8 (qt5sqld.dll) (in a.exe): 0xc0000005: an access violation occurred when reading position 0x0000000000000010
- 企鹅龙(DRBL)无盘启动+再生龙(clonezilla)网络备份与还原系统
- 2021-08-13 learn C language with pengge - array
- ISO 639:1988 : Code for the representation of names of languages
- C language pengge 20210812c language function
猜你喜欢

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

RT thread learning notes (VI) -- start the elmfat file system based on SPI flash (Part 1)

pytest pytest.ini配置 用例分组 用例跳过

Bash shell学习笔记(四)

35. Search the insertion position

Bash shell学习笔记(三)

349. Intersection of two arrays

Bash shell learning notes (VII)

242. Effective letter heteronyms

Wechat official account message notice "errCode": 40164, "errmsg": "invalid IP
随机推荐
logging基本使用
经典蓝牙的连接过程
flutter dart生成N个区间范围内不重复随机数List
Bash shell学习笔记(二)
HCI 接口
pytest 前后置方法
Simple use of MFC multithreading
Bash shell学习笔记(三)
Sword finger offer (49): convert a string to an integer
Sql Server之查询总结
Esxi6.5 patch update
Bash shell学习笔记(四)
访问权限——private,public,protected
ESXi6.5补丁更新
c结构体中定义的成员指针赋值与结构体指针作为成员函数参数的使用
Sword finger offer (52): regularization expression
Tutorial of putty
pytest pytest.ini配置 用例分组 用例跳过
Wechat official account message notice "errCode": 40164, "errmsg": "invalid IP
Bash shell学习笔记(七)