插件列表网址:https://plugincompat.herokuapp.com,包含了很多插件包

一、调整测试用例的执行顺序

安装:pip install pytest-ordering

在测试方法上加下面装饰器

@pytest.mark.last
#最后一个执行
@pytest.mark.run(order=1)
#第几个执行

二、用例失败重试

安装:pip install pytest-rerunfailures

命令行参数:--reruns n(重新运行次数),--reruns-delay m(等待运行秒数)

pytest --reruns 5

装饰器参数:reruns=n(重新运行次数),reruns_delay=m(等待运行秒数)

 @pytest.mark.flaky(reruns=5)

三、多重校验

如果需要多个断言,都执行就需要第三方插件 pytest-assume

安装:pip install pytest-assume

def test_add2(self):
    pytest.assume(add(1,2)==3)
    pytest.assume(add(1,4)==3)
    pytest.assume(add(2,2)==4)

四、pytest-html生成报告

安装:pip install pytest-html

命令行参数:--html=report.html

pytest --html=report.html

相关文章:

  • 2021-07-10
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2021-11-08
  • 2022-12-23
  • 2022-12-23
  • 2023-02-07
猜你喜欢
  • 2021-05-22
  • 2021-11-28
  • 2022-12-23
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
相关资源
相似解决方案