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/") # 指定测试目录

最新文章

  1. 超炫的HTML5粒子效果进度条 VS 如何规范而优雅地code
  2. Git命令回顾
  3. 【HDU 1003】 Max Sum
  4. Mac 如何截屏(快捷键)
  5. python基础:自定义函数
  6. 使用GitHub For Windows托管Visual Studio项目
  7. Linux 网络编程基础(3) -- 数据的IO
  8. c# winform读取xml创建菜单
  9. Sql 参数的使用
  10. HDU 1885 Key Task 国家压缩+搜索
  11. 兼容IE6及以上的导航栏子菜单栏滑过显示隐藏效果
  12. MySql数据库第一天
  13. HTML表格,table,thead,tbody,tfoot,th,tr,td,的属性以及跨行,跨列
  14. Docker+Consul+Registrator 实现服务注册与发现
  15. for in 循环 和for循环 for of循环
  16. c语言洗牌算法
  17. 配置SpringMvc + maven 数据源!(四)
  18. Spring cache 缓存
  19. linux -- Apache执行权限
  20. android.view.WindowLeaked的解决办法

热门文章

  1. WEB应用中的路径问题及乱码问题
  2. 当面试官问我ArrayList和LinkedList哪个更占空间时,我这么答让他眼前一亮
  3. SmartDb代码修改
  4. “随手记”开发记录day06
  5. Netty(一):的入门使用。
  6. 在Linux下安装nginx服务器详细教程
  7. Java并发--基础知识
  8. C#LeetCode刷题之#720-词典中最长的单词(Longest Word in Dictionary)
  9. 谈谈代码评审(code review)
  10. Deep learning-based personality recognition from text posts of online social networks 阅读笔记