pytest-配置项目不同环境URL

pytest自动化中,在不同环境进行测试,可以将项目中的url单独抽取出来,通过pytest.ini配置文件实现(类似postman中的"Environments")

使用步骤:

1)安装pytest-base-url插件

pytest-base-url 是一个pytest插件,它通过命令行或配置文件提供可选的基本 URL。

pycharm界面file-settings进行安装,如下图:

2)在pytest.ini配置文件中添加base-url环境

3)在测试用例中使用

在测试用例里直接传 base_url 参数,当做fixture函数使用(会调用pytets.ini里面的 base_url 地址), base_url 是pytest中的内置fixture函数

相关推荐
惜.己1 天前
pytest中使用ordering控制函数的执行顺序
开发语言·python·pytest
惜.己2 天前
pytest中使用skip跳过某个函数
开发语言·python·测试工具·pytest
程序员小远3 天前
Pytest+Selenium UI自动化测试实战实例
自动化测试·软件测试·python·selenium·测试工具·ui·pytest
惜.己5 天前
pytest简单使用和生成测试报告
开发语言·python·pytest
better-tomorrow5 天前
pytest-log
pytest
别在内卷了8 天前
测试学习之——Pytest Day4
python·学习·pytest
别在内卷了9 天前
测试学习之——Pytest Day3
python·学习·pytest
土小帽软件测试9 天前
mac系统安装、启动Jenkins,创建pytest接口自动化任务
macos·jenkins·pytest
Chasing__Dreams10 天前
pytest--1--pytest-mock常用的方法
pytest
chao_78910 天前
更灵活方便的初始化、清除方法——fixture【pytest】
服务器·自动化测试·python·pytest