PyTest装饰器

  1. 控制用例执行顺序的方法
  2. 在需要调整用例执行顺序的函数(或方法)前增加
    1. @pytest.mark.run(order=x) x表示数字
  3. 数字形式: 小数、整数、负数

执行顺序:

1、由小到大

2、由正到负

3、未标记 的在正数后,负数前执行

顺序: 1,2,3,无标记,-3,-2,-1

  1. 控制用例执行顺序的方法
  2. 在需要调整用例执行顺序的函数(或方法)前增加
    1. @pytest.mark.run(order=x) x表示数字
  3. 数字形式: 小数、整数、负数

执行顺序:

1、由小到大

2、由正到负

3、未标记 的在正数后,负数前执行

顺序: 1,2,3,无标记,-3,-2,-1

几个常用装饰,没有涉及的大家多多补充~

  1. pytest.ini 配置文件
    1. 例子: [pytest] addopts = -v -s --html=py_test/scripts/report/report.html -p no:warnings --reruns=10 testpaths = ./py_test/scripts python_files= test_rerun.py python_classes = Test* python_function = test* xfail_strict = true
相关推荐
bjwuzh2 天前
使用pytest实现参数化后,控制台输出的日志是乱码
pytest
2025年一定要上岸3 天前
pytest框架 - 第二集 allure报告
pytest
头疼的程序员4 天前
allure生成测试报告(搭配Pytest、allure-pytest)
测试工具·pytest
文人sec4 天前
接口自动化测试设计思路--设计实战
python·https·单元测试·自动化·pytest
测试开发Kevin6 天前
从投入产出、效率、上手难易度等角度综合对比 pytest 和 unittest 框架
python·pytest
测试开发Kevin8 天前
以pytest_addoption 为例,讲解pytest框架中钩子函数的应用
python·pytest
川石教育14 天前
Pytest中的fixture装饰器详解
python自动化测试·pytest·pytest自动化测试框架·pytest测试框架·pytest单元测试框架
春风又。14 天前
接口自动化——参数化
python·测试工具·自动化·pytest
XTY0016 天前
mac电脑pytest生成测试报告
pytest
程序员的世界你不懂17 天前
pytest-前后置及fixture运用
pytest