【pytest】(四) pytest的一些其他的运行用法
2024-10-09 14:23:10
1. 可以设置当失败N个后停止测试
pytest -x 是当第一个失败产生后,停止
pytest --maxfail=2, 这里就是当失败2个用例后,停止测试
2.pytest 在命令行模式下支持多种方式运行和选择运行
- pytest test_mod.py 运行这个文件(模块)
- pytest testing/ 运行指定目录下的测试文件
3. 指定运行文件下具体类下的具体方法,用:: 分隔 文件、类、 方法
pytest test_mod.py::TestClass::test_method
4.pytest中同样提供了main() 来函数来执行测试用例
import pytest
def test_main():
assert 5 != 5
if __name__ == '__main__':
pytest.main()
sublime, ctrl + b 即可运行
5.在main()下运行指定目录文件,也可以加参数,比如
import pytest
def test_main():
assert 5 != 5
if __name__ == '__main__':
pytest.main("d:/pyse/pytest/") # 指定测试目录
最新文章
- 超炫的HTML5粒子效果进度条 VS 如何规范而优雅地code
- Git命令回顾
- 【HDU 1003】 Max Sum
- Mac 如何截屏(快捷键)
- python基础:自定义函数
- 使用GitHub For Windows托管Visual Studio项目
- Linux 网络编程基础(3) -- 数据的IO
- c# winform读取xml创建菜单
- Sql 参数的使用
- HDU 1885 Key Task 国家压缩+搜索
- 兼容IE6及以上的导航栏子菜单栏滑过显示隐藏效果
- MySql数据库第一天
- HTML表格,table,thead,tbody,tfoot,th,tr,td,的属性以及跨行,跨列
- Docker+Consul+Registrator 实现服务注册与发现
- for in 循环 和for循环 for of循环
- c语言洗牌算法
- 配置SpringMvc + maven 数据源!(四)
- Spring cache 缓存
- linux -- Apache执行权限
- android.view.WindowLeaked的解决办法
热门文章
- WEB应用中的路径问题及乱码问题
- 当面试官问我ArrayList和LinkedList哪个更占空间时,我这么答让他眼前一亮
- SmartDb代码修改
- “随手记”开发记录day06
- Netty(一):的入门使用。
- 在Linux下安装nginx服务器详细教程
- Java并发--基础知识
- C#LeetCode刷题之#720-词典中最长的单词(Longest Word in Dictionary)
- 谈谈代码评审(code review)
- Deep learning-based personality recognition from text posts of online social networks 阅读笔记