当前位置:网站首页>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 
边栏推荐
- c结构体中定义的成员指针赋值与结构体指针作为成员函数参数的使用
- 0x00007ffd977c04a8 (qt5sqld.dll) (in a.exe): 0xc0000005: an access violation occurred when reading position 0x0000000000000010
- BigDecimal's addition, subtraction, multiplication and division, size comparison, rounding up and down, and BigDecimal's set accumulation, judge whether BigDecimal has decimal
- C language pengge 20210812c language function
- Sword finger offer (49): convert a string to an integer
- RT thread learning notes (VII) -- open the elmfat file system based on SPI flash (middle)
- Software Testing Overview: the background, essence and process of software testing
- 使用Selenium抓取zabbix性能监控图
- What are the biz layer and manager layer in the company project
- 349. 两个数组的交集
猜你喜欢
![Error[pe147]: declaration is incompatible with 'error problem](/img/4f/57145d78f4dc1fe84d2f271dd9d82f.png)
Error[pe147]: declaration is incompatible with 'error problem

@Notblank, @notnull, @notempty differences and uses

242. Effective letter heteronyms

Bash shell learning notes (II)

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

pytest 前后置方法

Bash shell学习笔记(一)

Flutter编译报错 version of NDK matched the requested version 21.0.6113669. Versions available locally: 2

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

mysql20210906
随机推荐
27.移除元素
SQL Server 之Sql语句创建数据库
BigDecimal's addition, subtraction, multiplication and division, size comparison, rounding up and down, and BigDecimal's set accumulation, judge whether BigDecimal has decimal
@JsonFormat和@DateTimeFormat的区别和使用
0x00007ffd977c04a8 (qt5sqld.dll) (in a.exe): 0xc0000005: an access violation occurred when reading position 0x0000000000000010
C language pengge 20210812c language function
flutter 背景变灰效果,如何透明度,灰色蒙板遮罩
-bash: ./build.sh: /bin/bash^M: 坏的解释器: 没有那个文件或目录
Software Testing Overview: the background, essence and process of software testing
RT thread learning notes (V) -- edit, download and debug programs
MFC中0x003b66c3 处有未经处理的异常: 0xC000041D: 用户回调期间遇到未经处理的异常
Esxi6.5 patch update
Minesweeping Pro version 2021-08-19
解决org.apache.commons.codec.binary.Base64爆红问题
按二进制数中1的个数分类
PLC与伺服电机连接
Pengge C language lesson 4 (3)
Newbie sees the source code arraydeque
WIRESHARK基础教程以太帧的分析。
RT thread learning notes (VI) -- start the elmfat file system based on SPI flash (Part 1)