入门6-Pytest全局配置文件

蜗牛果果 / 2023-05-07 / 原文

通过全局配置pytest.ini文件执行() //会自动加载此文件

注意:

一般放在项目根目录下,并且名字必须为pytest.ini

编码格式为ANSI,有中文需要GBS1218

pytest.ini可以改变默认测试用例规则

不管main还是命令方式都会自动加载此配置文件

内容举例:

[pytest] //代表配置文件

addopts = -vs -m "High"
testpaths = ./testcases
python_files = test_*.py
python_classes = Test*
python_functions = test_*
markers = //用于分类执行
    High: smoke test
    Normal: product test
    Low: full test cases

marhang: 商品

product_manage: 生产

user_manage: 用户