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] [Part 2]增加 log功能
开发语言·python·pytest
思则变2 天前
[Pytest][Part 3]检测python package状态
pytest
cooldream200916 天前
pytest 框架详解与实战指南
pytest·测试
慕城南风16 天前
【pytest进阶】Pytest之conftest详解
pytest
编程小白gogogo17 天前
AI自动化测试速成(Pytest框架)
pytest
慕城南风17 天前
【pytest进阶】pytest详解及进阶使用
linux·服务器·pytest
Tom Boom23 天前
Pytest断言全解析:掌握测试验证的核心艺术
自动化测试·python·测试开发·pytest
不要一直敲门25 天前
初学 pytest 记录
pytest
测试界清流25 天前
Selenium4+Pytest自动化测试框架
selenium·测试工具·pytest