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函数

相关推荐
鲜于言悠9051 天前
博客系统测试报告
python·功能测试·selenium·jmeter·测试用例·集成测试·pytest
0和1的舞者2 天前
高并发论坛系统:单元测试 + 接口自动化 + 性能测试 + CI/CD 全链路测试报告
java·测试开发·测试工具·jmeter·pytest·测试·测试报告
独断万古他化2 天前
Python+Pytest 搭建博客系统接口自动化测试框架(全用例执行+完整代码)
pytest·接口自动化·测试·allure·requests
王夏奇2 天前
python-pytest学习
python·学习·pytest
独断万古他化3 天前
Python 接口测试之 requests 库核心用法
python·pytest·接口测试·requests
姚青&3 天前
Pytest 测试用例生命周期管理-fixture
测试用例·pytest
姚青&17 天前
PyCharm 配置与界面化运行
pytest
姚青&17 天前
Pytest 测试用例断言
测试用例·pytest
姚青&17 天前
Pytest 命名规则
pytest
姚青&17 天前
Pytest 测试用例结构
测试用例·pytest