欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 时评 > D87【python 接口自动化学习】- pytest基础用法

D87【python 接口自动化学习】- pytest基础用法

2025/2/9 11:38:41 来源:https://blog.csdn.net/tian_nx/article/details/144226938  浏览:    关键词:D87【python 接口自动化学习】- pytest基础用法

day87 pytest运行参数 -m -k

学习日期:20241203

学习目标:pytest基础用法 -- pytest运行参数-m -k

学习笔记:

常用运行参数

pytest运行参数-m -k
  • pytest -m 执行特定的测试用例,markers最好使用英文
[pytest]
testpaths=./test_requests
markers=p0=高优先级test=测试环境pro=生产环境
import pytest@pytest.mark.p0
def test_one():expect = 1actual = 1assert expect == actual@pytest.mark.test
def test_two():expect = 1actual = 2assert expect == actualdef two():expect = 1actual = 2assert expect == actual

然后Treminal里执行: pytest -m 'test',只会执行标记test用例

Treminal里执行: pytest -m 'pro' ,只会执行标记Pro用例

  • pytest -k 执行用例包含“关键字”的用例
pytest -k 'mobile'
总结
  1. Treminal里执行: pytest -m 'test',只会执行标记为test的用例
  2. Treminal里执行: pytest -m 'pro' ,只会执行标记为pro的用例
  3. Treminal里执行: pytest -k 执行用例包含“关键字”的用例

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com