练习:
接口地址: Swagger UI
接口:
post /pet 新增
get /pet/findByStatus 查询
要求:
- 使用pytest对上述两个接口进行冒烟测试
- 添加allure step
- 断言相应状态码
示例:
@allure.feature("宠物商店宠物信息接口测试")
class TestPetstore:
def setup_class(self):
# 基础的数据信息
pass
@allure.story("查询宠物接口冒烟用例")
def test_getpet(self):
'''
获取宠物信息
:return:
'''
get_url = self.url + "/findByStatus"
with allure.step("发出查询接口请求"):
r = requests.get(get_url, self.find_parmas)
with allure.step("获取查询接口响应"):
print(r.json())
with allure.step("查询接口断言"):
assert r.status_code == 200