pytest-repeat插件,指定用例重复运行、重复运行次数

pytest-repeat是pytest的插件:(pytest-repeat 无法支持使用unittest.TestCase测试类)

作用:
用于重复执行单个用例,或多个测试用例,并指定重复次数,
安装:
pip install pytest-repeat
使用:
--count命令,指定要运行测试用例和测试次数:pytest --count=10 test_demo.py

 

注:
--repeat-scope类似于 @pytest fixture()的scope参数,
--repeat-scope也可设置参数: 默认的function、module、session 、class
使用:pytest test_demo.py   -s   --count=5  --repeat-scope=session

另:
结合使用mark标记来重复执行:
@pytest.mark.repeat(count)

使用:@pytest.mark.repeat(3) #在要重复执行的case上加上这个装饰器即可,运行时会默认运行指定次数3

posted on 2020-07-08 21:56  QiKa  阅读(1033)  评论(0编辑  收藏  举报