如何通过Pytest结合yaml实现参数化接口测试实战?

2026-05-21 14:490阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计109个文字,预计阅读时间需要1分钟。

如何通过Pytest结合yaml实现参数化接口测试实战?

直接输出简化后的代码:

python@pytest.mark.parametrize(mobile, appkey, get_data([mobile_belong_get]))def test_mobile(mobile, appkey): r=requests.get('https://api.binstd.com/shouji/query', params={shouj: mobile})

一、废话不罗嗦,直接上代码

@pytest.mark.parametrize("mobile, appkey", get_data["mobile_belong_get"])
def test_mobile(mobile, appkey):

r = requests.get('api.binstd.com/shouji/query', params={
"shouji": mobile,
"appkey": appkey
})
print(r.status_code)
assert r.status_code == 200
print(r.json())
print("zhou")

二、yaml数据

如何通过Pytest结合yaml实现参数化接口测试实战?

本文共计109个文字,预计阅读时间需要1分钟。

如何通过Pytest结合yaml实现参数化接口测试实战?

直接输出简化后的代码:

python@pytest.mark.parametrize(mobile, appkey, get_data([mobile_belong_get]))def test_mobile(mobile, appkey): r=requests.get('https://api.binstd.com/shouji/query', params={shouj: mobile})

一、废话不罗嗦,直接上代码

@pytest.mark.parametrize("mobile, appkey", get_data["mobile_belong_get"])
def test_mobile(mobile, appkey):

r = requests.get('api.binstd.com/shouji/query', params={
"shouji": mobile,
"appkey": appkey
})
print(r.status_code)
assert r.status_code == 200
print(r.json())
print("zhou")

二、yaml数据

如何通过Pytest结合yaml实现参数化接口测试实战?