一絮宁、測試步驟
- 方式1:測試用例內(nèi)部加步驟
- 方式2:測試用例字方法上加步驟(裝飾器@allure.step('描述')
二、測試用例內(nèi)加步驟
def test_sign_up(self,i_user_name,i_pwd,i_repwd,i_phone,o_code,o_userId,o_msg):
with allure.step('第1步:取地址'):
url = conf.gy_api + '/signup'
with allure.step('第2步:替換用例數(shù)據(jù)'):
if i_user_name=='自動生成':
i_user_name = gen_data_tool.get_name_pinyin()+
str(gen_data_tool.get_number(1,10))
if i_pwd == '自動生成':
i_pwd = gen_data_tool.get_pwd()
i_repwd = i_pwd
if i_phone == '自動生成':
i_phone = gen_data_tool.get_tell()
request = {
"phone": i_phone,
"pwd": i_pwd,
"rePwd": i_repwd,
"userName": i_user_name
}
print(request)
with allure.step('第3步:發(fā)送請求'):
response = request_tool.post_request(url=url, json=request)
print(response.json())
print(response.request)
with allure.step('第4步:判斷結果'):
assert_tool.assert_code(response.status_code, 200)
if o_code != '':
assert_tool.assert_text(response.json()['code'], o_code)
if o_userId == 'not null':
assert_tool.assert_not_null(response.json()['data']['userId'])
二脱茉、示例
class TestSignUp:
def login(self):
url = ''
req = {
"pwd": "string",
"userName": "string"
}
allure.attach(req, '請求', allure.attachment_type.TEXT)
resp = requests.post(url, json=req)
allure.attach(resp.text, '響應', allure.attachment_type.TEXT)
三非驮、查看報告
image.png
image.png