引言 pytest.ini文件配置可以改变pytest运行的方式。推荐:pytest.ini存放在项目根目录中。pytest.ini采用“key-value”方式来定义相关参数。

1.pytest.ini简述

pytest.ini文件存放在“项目根目录”中,可以作为“全局配置”来改变“pytest的运行方式”。

2.pytest.ini的参数项

参数 【指定运行的】说明
makers 注册maker标记
addopts 更改默认命令行参数
python_file__s 文件
python_classes
python_function 方法
testpaths 目录
norecursedirs (不执行的)目录
minversion pytest的最低版本号

【学习】https://www.yuque.com/guzhenhua-scpnj/bl8vmr/rmqbao

  1. [pytest]
  2. python_classes = Test*
  3. python_functions = test_*
  4. addopts = -sv --alluredir ./reports/allure-results --clean-alluredir
  5. testpaths = testCase testCase2021