前言
-
日常业务测试过程中,经常会遇到偶现的bug,需要重复操作来复现bug
-
自动化测试同样如此,也会需要重复执行用例,来确定用例的稳定性、成功性和复现偶现的bug
-
pytest-repeat 是 pytest 的一个插件,可以重复的执行单个测试或多个测试,也可以自定义重复执行的次数
-
官方文档:https://pypi.org/project/pytest-repeat/
前提条件
- Python 2.7、3.5+ 或 PyPy
- pytest 3.6 或更高版本
插件安装
pip3 install pytest-repeat -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
参数介绍
- –count :指定重复运行的次数
使用详解
举个🌰
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
"""
__File__ = test_case1.py
__Project__= _JAuto-Interface
__Time__ = 2022-03-02 16:57:54
__Author__ = 黎晟
"""
def test_1():
print("测试用例1")
def test_2():
print("测试用例2")
执行命令
pytest -vs <