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

相关推荐
努力搬砖的咸鱼19 小时前
从零开始搭建 Pytest 测试框架(Python 3.8 + PyCharm 版)
python·pycharm·pytest
FINE!(正在努力!)3 天前
PyTest框架学习
学习·pytest
程序员杰哥3 天前
接口自动化测试之pytest 运行方式及前置后置封装
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·pytest
测试老哥4 天前
Pytest+Selenium UI自动化测试实战实例
自动化测试·软件测试·python·selenium·测试工具·ui·pytest
水银嘻嘻4 天前
07 APP 自动化- appium+pytest+allure框架封装
python·appium·自动化·pytest
天才测试猿4 天前
接口自动化测试之pytest接口关联框架封装
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·pytest
not coder5 天前
Pytest Fixture 详解
数据库·pytest
not coder6 天前
pytest 常见问题解答 (FAQ)
开发语言·python·pytest
程序员的世界你不懂6 天前
(1)pytest简介和环境准备
pytest
not coder6 天前
Pytest Fixture 是什么?
数据库·oracle·pytest