首页 > 其他分享 >pytest如何重复执行用例?

pytest如何重复执行用例?

时间:2023-02-12 11:33:41浏览次数:35  
标签:__ 插件 repeat 重复 mark 用例 pytest

安装:

  需要用到 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解析器中手动安装, 即可解决报错问题

 

标签:__,插件,repeat,重复,mark,用例,pytest
From: https://www.cnblogs.com/FBGG/p/17113521.html

相关文章