python——pytest对于失败的用例重新执行

python pytest自动化测试时,对于失败的用例可以重跑,这就避免了偶然性fail的影响

安装:

1、pip install pytest-rerunsfailures

2、如果需要html的测试报告,需要安装:pip install pytest-html

三种方式:

方法1:在python自动化项目根目录下新建pytest.ini,在配置文件中写入以下内容:

[pytest]
addpots = -vs --reruns 1 --reruns-delay 60

        其中:reruns为失败用例重跑的次数(此处为1次,也可以为2、3次),reruns-delay为间隔时间,单位为s

方法2:在想要重跑的用例前加上@pytest.mark.flaky(reruns=2,reruns-delay=2)

方法3:命令行参数:pytest --reruns 重试次数(--reruns-delay 次数之间间隔)

pytest --reruns 2 运行失败的用例可以执行2次
pytest --reruns 2 --reruns-delay5 运行失败的用例可以执行2次,每次间隔5s

相关推荐

  1. python——pytest对于失败重新执行

    2024-03-22 02:32:01       49 阅读
  2. pytest+allure批量执行测试

    2024-03-22 02:32:01       53 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-22 02:32:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-22 02:32:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-22 02:32:01       82 阅读
  4. Python语言-面向对象

    2024-03-22 02:32:01       91 阅读

热门阅读

  1. nodejs的中雪花算法(Snowflake)

    2024-03-22 02:32:01       43 阅读
  2. solr functionquery函数查询自定义函数实现

    2024-03-22 02:32:01       47 阅读
  3. 每天学习几道面试题|Kafka(二)架构设计类

    2024-03-22 02:32:01       44 阅读
  4. 美易官方:特斯拉暴跌实是“抄底良机”?

    2024-03-22 02:32:01       45 阅读
  5. Chapter 1 - 2. Introduction to Congestion in Storage Networks

    2024-03-22 02:32:01       39 阅读
  6. mysql日志( Redo Log 、Undo Log、Bin Log)

    2024-03-22 02:32:01       42 阅读