当前位置:网站首页>pytest接口自动化测试框架 | 控制测试用例执行
pytest接口自动化测试框架 | 控制测试用例执行
2022-07-23 12:18:00 【COCOgsta】
视频来源:B站《冒死上传!pytest接口自动化测试框架(基础理论到项目实战及二次开发)教学视频【软件测试】》
一边学习一边整理老师的课程内容及试验笔记,并与大家分享,侵权即删,谢谢支持!
附上汇总贴:pytest接口自动化测试框架 | 汇总_COCOgsta的博客-CSDN博客
在第N个用例失败后,结束测试执行
pytest --maxfail=2 # 出现2个失败就终止测试
import pytest
# 失败
def test_fail01():
print("第一次失败")
assert 1==2
def test_fail02():
print("第二次失败")
assert 1 == 2
def test_hello():
print("第三次成功")
assert 1 == 1
if __name__ == '__main__':
pytest.main(["--maxfail=2", "test_fail2.py"])发现直接在pycharm中执行不生效,但用命令行执行生效
PS D:\SynologyDrive\CodeLearning\WIN\pytest\base_used> pytest .\test_fail2.py --maxfail 2
======================================================================================================== test session starts ========================================================================================================
platform win32 -- Python 3.6.6, pytest-7.0.1, pluggy-1.0.0
rootdir: D:\SynologyDrive\CodeLearning\WIN\pytest\base_used
plugins: allure-pytest-2.9.45, forked-1.4.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.2, xdist-2.5.0
collected 3 items
test_fail2.py FF
============================================================================================================= FAILURES ==============================================================================================================
____________________________________________________________________________________________________________ test_fail01 ____________________________________________________________________________________________________________
def test_fail01():
print("第一次失败")
> assert 1==2
E assert 1 == 2
test_fail2.py:6: AssertionError
------------------------------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------------------------------
第一次失败
____________________________________________________________________________________________________________ test_fail02 ____________________________________________________________________________________________________________
def test_fail02():
print("第二次失败")
> assert 1 == 2
E assert 1 == 2
test_fail2.py:11: AssertionError
------------------------------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------------------------------
第二次失败
====================================================================================================== short test summary info ======================================================================================================
FAILED test_fail2.py::test_fail01 - assert 1 == 2
FAILED test_fail2.py::test_fail02 - assert 1 == 2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 2 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================================================================================= 2 failed in 0.09s =========================================================================================================
PS D:\SynologyDrive\CodeLearning\WIN\pytest\base_used>
边栏推荐
- Kubernetes 基本概念和部署
- Remote system command execution
- Why does fatal always appear when using opengaussjdbc? (tag database keyword user)
- MySQL soul 16 ask, how many questions can you hold on to?
- STM32F103+RFID-RC522模块 实现简单读卡写卡demo「建议收藏」
- Mailbox communication-
- 将.calss文件转为.jar-idea篇
- High cost performance, high anti-interference touch IC that meets a variety of keys: vk3606d, vk3610i, vk3618i have high power voltage rejection ratio
- Purpose of wsastartup function
- pgsql误删除pg_wal文件后,服务启动失败
猜你喜欢

Ali Er Mian: when does MySQL use table locks and row locks?

Custom JSTL tag of JSP

自定义一个对象

Origin of bean validation ----01

js过滤/替换敏感字符

Dark horse programmer - interface test - four day learning interface test - third day - advanced usage of postman, export and import of Newman case set, common assertions, assertion JSON data, working

激光共聚焦如何选择荧光染料

死锁、饥饿、死循环之间的区别

Bean validation core components - 04

C#中单例模式的实现
随机推荐
V自P建N_部署使用
Flutter 组件的生命周期、State 管理及局部重绘 | 开发者说·DTalk
Transparent proxy server architecture of squid proxy service
[in simple terms] from self information to entropy, from relative entropy to cross entropy, nn Crossentropyloss, cross entropy loss function and softmax, multi label classification
From the big guy baptism! 2022 headline first hand play MySQL advanced notes, and it is expected to penetrate P7
[SUCTF 2018]MultiSQL(mysql预编译)
VMware platform STS certificate expired
Purpose of wsastartup function
High cost performance, high anti-interference touch IC that meets a variety of keys: vk3606d, vk3610i, vk3618i have high power voltage rejection ratio
2022蓝帽杯初赛wp
Mysql—主从复制
聊一聊JVM的内存布局
【深入浅出向】从自信息到熵、从相对熵到交叉熵,nn.CrossEntropyLoss, 交叉熵损失函数与softmax,多标签分类
W3C introduces decentralized identifier as web standard
It's too hard! Tencent T4 boss was still staying up late at 4 a.m. and was actually sorting out the distributed transaction notes
知道为什么PCBA电路板会板翘吗?
信箱通信-
Memory methods of big end mode and small end mode
MySQL中几种常见的 SQL 错误用法
mysql多表查询之_内连接_显示内连接