当前位置:网站首页>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>
边栏推荐
- 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
- 阿里二面:MySQL 啥时候用表锁,啥时候用行锁?
- “1+1>10”:无代码/低代码与RPA技术的潜在结合
- 牛客-TOP101-BM35
- Governance and network security of modern commercial codeless development platform
- Flutter | 给 ListView 添加表头表尾最简单的方式
- Google Earth engine -- null value problem in image statistics
- 2022 blue hat cup preliminary WP
- 现代商业无代码开发平台的治理和网络安全
- table自定义表格的封装
猜你喜欢

The competition boss is in Huawei: network experts are from Stanford physics department, and some people "work as much as reading a doctoral degree"
10": potential combination of no code / low code and RPA Technology"/>"1+1 > 10": potential combination of no code / low code and RPA Technology

Another award | opensca was selected as the "top ten open source software products in the world" at the China Software Expo

MySQL - six logs

【云原生】持续集成和部署(Jenkins)

VMWARE平台STS证书过期

Custom JSTL tag of JSP

After effects tutorial, how to create animation in after effects?

死锁的3种处理策略

ICML 2022 | sparse double decline: can network pruning also aggravate model overfitting?
随机推荐
Transparent proxy server architecture of squid proxy service
MySQL soul 16 ask, how many questions can you hold on to?
Differences between LRU and LFU elimination strategies in redis
[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
VMWARE平台STS证书过期
自定义一个对象
Mysql—主从复制
20220722挨揍记录
Nport serial server principle, moxa serial server nport-5130 detailed configuration
W3C introduces decentralized identifier as web standard
Mailbox communication-
pgsql误删除pg_wal文件后,服务启动失败
2022 blue hat cup preliminary WP
【2022新生学习】第二周要点
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
Comparison of functional characteristics and parameters of several solar panel battery charging management ICs cs5363, cs5350 and cs5328
Origin of bean validation ----01
Jianzhi offer II 115. reconstruction sequence: topological sorting construction problem
快递单证智能OCR识别,助力物流行业数字化升级
After effects tutorial, how to create animation in after effects?