allure-13-測(cè)試步驟step

一、測(cè)試步驟

  1. 方式1:測(cè)試用例內(nèi)部加步驟
  2. 方式2:測(cè)試用例字方法上加步驟(裝飾器@allure.step('描述')

二、測(cè)試用例內(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=='自動(dòng)生成':
                i_user_name = gen_data_tool.get_name_pinyin()+
                            str(gen_data_tool.get_number(1,10))
            if i_pwd == '自動(dòng)生成':
                i_pwd = gen_data_tool.get_pwd()
                i_repwd = i_pwd
            if i_phone == '自動(dòng)生成':
                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ā)送請(qǐng)求'):
            response = request_tool.post_request(url=url, json=request)
            print(response.json())
            print(response.request)

        with allure.step('第4步:判斷結(jié)果'):
            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, '請(qǐng)求', allure.attachment_type.TEXT)
        resp = requests.post(url, json=req)
        allure.attach(resp.text, '響應(yīng)', allure.attachment_type.TEXT)

三、查看報(bào)告

image.png
image.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容