pytest之配置文件pytest.ini笔记

3 阅读1分钟
[pytest]
;用例查找规则
testpaths = testcase
python_files = test_*.py
python_classes = Test*
python_functions = test_*
;只去 testcase 文件夹找用例
;只运行 test_ 开头的文件
;只运行 Test 开头的类
;只运行 test_ 开头的函数

;标签标记
markers =
    smoke:冒烟测试
    api:接口测试
    regression:回归测试
;打的标签必须在这里声明,否则报警告

;默认运行参数
addopts = -v --reruns=1 --alluredir=allure-results --clean-alluredir
;显示详细结果 -v
;失败重跑 1 次 --reruns=1
;生成 allure 报告
;自动清空旧报告

# 编码
disable_test_id_escaping_and_forfeit_all_rights_to_community_support = true

;运行
;运行整个项目
pytest
;运行整个文件夹
pytest testcase/
;运行单个文件
pytest testcase/test_demo.py
;只运行冒烟
pytest -m smoke
;只运行某个类
pytest testcase/test_demo.py::TestDemo
;只运行单个用例
pytest testcase/test_demo.py::TestDemo::test_login