当前位置:网站首页>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 
边栏推荐
- Multipartfil to file
- -bash: ./build.sh: /bin/bash^M: 坏的解释器: 没有那个文件或目录
- logging 学习最终版-配置的不同级别日志打印的颜色
- 菜鸟看源码之LinkedBlockingQueue
- HCI 接口
- 字典与int矩阵
- How to assemble a registry?
- RT thread learning notes (I) -- configure RT thread development environment
- @NotBlank、@NotNull 、@NotEmpty 区别和使用
- Pengge C language 20210811 program structure operation
猜你喜欢

Bash shell learning notes (V)

0x00007FFD977C04A8 (Qt5Sqld.dll)处(位于 a.exe 中)引发的异常: 0xC0000005: 读取位置 0x0000000000000010 时发生访问冲突

Esxi6.5 patch update

Bash shell learning notes (4)

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

SCADA and three industrial control systems PLC, DCS and FCS

Bash shell learning notes (VII)

母亲

Wireshark basic tutorial Ethernet frame analysis.

35. Search the insertion position
随机推荐
232.用栈实现队列
Visual conversion of nmap vulnerability scanning results
WIRESHARK基础教程以太帧的分析。
RT thread learning notes (V) -- edit, download and debug programs
Definition and use of C language namespace
Newbie sees the source code arraydeque
经典蓝牙的连接过程
Flutter集成极光推送
RT thread learning notes (VIII) -- start the elmfat file system based on SPI flash (Part 2)
Analysis of C # delegation and anonymous method
Sql Server 数据库之初学体验
菜鸟看源码之SparseArray
Simple use of MFC multithreading
RT thread learning notes (VII) -- open the elmfat file system based on SPI flash (middle)
Flutter CachedNetworkImage圆角
The assignment of member pointer defined in C structure and the use of structure pointer as member function parameter
Fragment lazy load
Bash shell learning notes (VII)
SCADA and three industrial control systems PLC, DCS and FCS
Wechat official account message notice "errCode": 40164, "errmsg": "invalid IP