建議收藏:async 與 promise 的區別
阿新 • • 發佈:2022-03-09
自動化用例
#coding=utf-8 """ 【自動化用例】 feature 特性名稱 story 使用者故事/場景 title 對應用例的標題 testcase 對應禪道系統的bug用例url地址,關聯起來 issue 如果這個用例有bug,應該關聯對應的bug地址 step 用例步驟描述 功能用例整體描述:寫在用例方法的註釋裡 """ import os import allure import pytest @allure.feature("編輯分類文章") class TestArticaleClassify(): @allure.story("典型場景") @allure.title(allure.feature"編輯文章分類,重複儲存,儲存失敗") @allure.issue("http://127.0.0.1:8080/zentao/bug-view-1.html") #禪道bug地址 @allure.testcase("http://127.0.0.1:8080/zentao/testcase-view-5-1.html") #禪道用例連結地址 def test_edit_classify(self): """ 編輯文章分類,重複儲存,儲存失敗 前置條件:1.登入 步驟: 1.編輯文章分類,輸入文章類別,如計算機 2.點選儲存按鈕 3.重新開啟編輯頁面,輸入:計算機 4.再次點選儲存按鈕 預期結果: 1.輸入成功 2.儲存成功 3.輸入成功 4.儲存失敗,提示:已存在""" with allure.step("step:登陸"): print("登陸") assert 1 == 1 with allure.step("step1:編輯文章分類,輸入文章類別,如計算機"): print("step1") assert 1 == 1 with allure.step("step2:點選儲存按鈕"): print("step2") assert 1 == 1 with allure.step("step3:重新開啟編輯頁面,輸入:計算機"): print("step3") assert 3 == 4 with allure.step("step4:再次點選儲存按鈕"): print("step4") assert 4 == 5 if __name__ == '__main__': pytest.main(['--alluredir','./muzi']) os.system('allure generate ./muzi/ -o ./report/ --clean')
【用例等級設定】
#coding=utf-8 """ 用例等級 allure對用例的等級劃分成五個等級: blocker 阻塞缺陷(功能未實現,無法下一步) critical 嚴重缺陷(功能點缺失) normal 一般缺陷(邊界情況,格式錯誤) minor 次要缺陷(介面錯誤與ui需求不符) trivial 輕微缺陷(必須項無提示,或者提示不規範) """ import os import allure import pytest @allure.severity("normal") def test_case_1(): """ 修改個人姓名-置空 """ print("用例1111") @allure.severity("critical") def test_case_2(): """ 修改個人資訊-設定為系統已有人員的資訊 """ print("用例2222") @allure.severity("critical") def test_case_3(): """ 修改個人姓名-生日必選項置空儲存 """ print("用例3333") @allure.severity("blocker") def test_case_4(): """ 修改個人姓名-點選儲存成功 """ print("用例4444") def test_case_5(): """ 不設定等級,預設等級為 """ print("用例5555") if __name__ == '__main__': pytest.main(['--alluredir','./muzi']) # 如果有很多測試用例,現在想做快速回顧,只執行用例級別為blocker和critical的測試用例 # pytest.main(['--alluredir', './muzi', '--allure-severities', 'blocker,critical']) # pytest.main(['--alluredir','./muzi','--allure-severities','blocker,critical','--clean-alluredir']) os.system('allure generate ./muzi/ -o ./report/ --clean') # os.system('allure serve muzi')severities