首页 » 软件开发 » 软件测试学习笔记丨Pytest配置文件(pytest.ini)(测试日志配置执行配置文件)

软件测试学习笔记丨Pytest配置文件(pytest.ini)(测试日志配置执行配置文件)

雨夜梧桐 2024-07-24 03:29:31 软件开发 0

扫一扫用手机浏览

文章目录 [+]

python_files = check_ test_

2、执行所有的以Test和Check开头的类

python_classes = Test Check

3、执行所有以test_和check_开头的方法

python_functions = test_ check_

pytest配置-添加默认参数

addopts = -v -s --alluredir = ./results

pytest配置- 指定/忽略执行目录设置执行的路径

testpaths = bilibili baidu

忽略某些文件夹/目录

norecursedirs = result logs datas test_demo

pytest配置-日志

[pytest];日志开关 true falselog_cli = true;日志级别log_cli_level = info;打印详细日志,相当于命令行加 -vsaddopts = --capture=no;日志格式log_cli_format = %(asctime)s [%(levelname)s] %(message)s (%(filename)s:%(lineno)s);日志时间格式log_cli_date_format = %Y-%m-%d %H:%M:%S;日志文件位置log_file = ./log/test.log;日志文件等级log_file_level = info;日志文件格式log_file_format = %(asctime)s [%(levelname)s] %(message)s (%(filename)s:%(lineno)s);日志文件日期格式log_file_date_format = %Y-%m-%d %H:%M:%S

总结pytest.ini1、修改用例的命名规则2、配置日志格式,比代码配置更方便3、指定执行目录4、排除搜索目录5、添加标签,防止运行过程报警告错误6、添加默认参数免费领取:测试资料+性能测试+接口测试+自动化测试+测试开发+测试用例+简历模板+测试文档 - 公众号 - 测试人社区

标签:

相关文章