pytest配置文件
pytest配置文件有固定的三个名称
三个取一个进行配置即可
配置文件要在项目的根目录
- pytest.ini
- tox.ini
- setup.cfg
pytest.ini配置文件常见样本
在配置文件中不能有注释
# [pytest]表示这是一个pytest配置文件
[pytest]
# addopts 表示执行pytest时加的参数
# pytest默认的报告参数是 --html=report/report.html
addopts = -s -vvv --alluredir=./report/测试报告
# testpaths 表示测试用例脚本的目录
testpaths = ./testcase
# python_files 表示匹配的测试用例脚本的文件前缀
python_files = test_*.py
# python_classes 表示匹配的测试类名称的前缀
python_classes = Test*
# python_functions 表示匹配的测试方法名称的前缀
python_functions = test_*
应用pytest.ini配置文件
配置好pytest.ini配置文件之后,运行用例时,不需要再加额外参数了,直接在命令行cd到项目目录下执行pytest
命令即可,会根据配置文件的定义自动搜索testcase目录下的测试用例.