Pytest 插件

一. Pytest 插件简介

Pytest 插件是 Python 包或模块,可以提供额外的功能、自定义行为或报告,可以根据项目的需求选择并使用不同的插件。


二. Pytest 常用的插件

  • 🔹 控制用例的执行顺序(重点)pip install pytest-ordering

  • 🔹 分布式并发执行测试用例(重点)pip install pytest-xdist

  • 🔹 控制用例的依赖关系(了解)pip install pytest-dependency

  • 🔹 多重较验(了解)pip install pytest-assume

  • 🔹 失败重跑(了解)pip install pytest-rerunfailures

  • 🔹 用例随机执行(了解)pip install pytest-random-order

  • 🔹 测试报告(了解)pip install pytest-html


三. Pytest 插件分类

  • Pytest 插件可以按其功能和用途进行分类。

外部插件

  • 通过 pip install 命令从 PyPI 或其他 Python 包索引安装的插件。

  • 外部插件是独立于项目的,可以在项目外安装它们并在项目中引用。

    • 例如,可以使用 pip 来安装 pytest-html 插件:pip install pytest-html。一旦安装,可以在任何项目中使用它来生成 HTML 测试报告。

内部插件

  • Pytest 内置了一些插件,这些插件提供了许多常见的功能和扩展。这些插件存储在 pytest 的内部目录(通常是_pytest目录)中,并自动加载,无需额外的安装或配置。

    • 例如,pytest.mark 就是一个内置插件。
相关推荐
昔我往昔5 天前
pytest日志问题排查记录
python·pytest
黄昏恋慕黎明8 天前
博客论坛技术迭代
python·pytest
2601_962078238 天前
Python接口自动化流程(pytest)
python·pytest·接口自动化·测试框架·断言
杨女士YRJ8 天前
python+pytest+01
python·pytest
2601_962078239 天前
Python接口自动化框架:pytest
python·pytest·接口自动化·测试框架·restfulapi
2601_962078199 天前
Appium+Python+pytest自动化测试框架详解
自动化测试·python·appium·pytest·移动应用
2601_9622845011 天前
安卓APP UI自动化测试:Python + UiAutomator2 + pytest + pytest-html
python·pytest·uiautomator2·ui自动化测试·安卓app
2601_9623008111 天前
基于pytest的接口自动化测试:使用requests模块的实战项目与接口关联方法详解
接口自动化测试·测试用例·pytest·接口关联·requests模块
2601_9623008111 天前
Python + Requests + Pytest + Excel + Allure:接口自动化测试项目实战
python·excel·pytest·allure·requests
11路没有终点12 天前
Pytest 安装、版本与第一个测试用例
测试用例·pytest