<13>pytest:pytest-xdist

目录:测试自动化学习 - pytest
说明:本篇博客基于pytest 6.2.5



作用

实现pytest分布式执行

安装

pip install pytest-xdist

使用

终端命令:pytest -n 线程数量

注:

  • 用例之间保持独立,不能有依赖关系
  • 用例无顺序关系,可以随机执行
  • 用例可以重复执行,运行结果不会影响其他用例
import time


def test_case1():
    time.sleep(1)
    assert True


def test_case2():
    time.sleep(1)
    assert True


def test_case3():
    time.sleep(1)
    assert True

运行语句:
pytest -n 4 test_xdist.py -vs

posted @ 2021-12-07 12:54  漓白  阅读(70)  评论(0编辑  收藏  举报