安装:
需要用到 pytest-repeat 插件, 安装该插件 pip install pytest-repeat
使用(成功用例重复执行):
使用 @pytest.mark.repeat(次数)
import pytest
class TestAa:
@pytest.mark.repeat(3)
def test001(self):
print('用例1')
def test002(self):
print('用例2')
if __name__ == '__main__':
pytest.main(['-v','./test_002.py'])
注意事项:
如果执行时报 Unknown pytest.mark.repeat - is this a typo? 错误 , 那可能是你插件没安装成功, 需要进入pycharm的设置>python解析器中手动安装, 即可解决报错问题