国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

網(wǎng)站規(guī)劃書包括哪些方面公司官網(wǎng)怎么制作

網(wǎng)站規(guī)劃書包括哪些方面,公司官網(wǎng)怎么制作,用c 做網(wǎng)站設(shè)計系統(tǒng)的項目作業(yè),邯鄲建設(shè)信息網(wǎng)站前言 在編寫自動化測試用例的時候經(jīng)常會遇到需要編寫流程性測試用例的場景,一般流程性的測試用例的測試步驟比較多,我們在測試用例中添加詳細(xì)的步驟會提高測試用例的可閱讀性。 allure提供的裝飾器allure.step()是allure測試報告框架非常有用的功能&am…

前言

在編寫自動化測試用例的時候經(jīng)常會遇到需要編寫流程性測試用例的場景,一般流程性的測試用例的測試步驟比較多,我們在測試用例中添加詳細(xì)的步驟會提高測試用例的可閱讀性。

allure提供的裝飾器@allure.step()是allure測試報告框架非常有用的功能,它能幫助我們在測試用例中對測試步驟進(jìn)行詳細(xì)的描述。

@allure.step的使用例子:

實現(xiàn)一個購物的場景:1.登錄;2.瀏覽商品;3.將商品加入到購物車中;4.下單;5.支付訂單;

# file_name: test_allure_step.pyimport pytest
import allure@allure.step
def login():"""執(zhí)行登錄邏輯:return:"""print("執(zhí)行登錄邏輯")@allure.step
def scan_good():"""執(zhí)行瀏覽商品邏輯:return:"""print("執(zhí)行瀏覽商品邏輯")@allure.step
def add_good_to_shopping_car():"""將商品添加到購物車:return:"""print("將商品添加到購物車")@allure.step
def generator_order():"""生成訂單:return:"""print("生成訂單")@allure.step
def pay():"""支付訂單:return:"""print("支付訂單")def test_buy_good():"""測試購買商品:步驟1:登錄步驟2:瀏覽商品步驟3:將商品加入到購物車中步驟4:下單步驟5:支付:return:"""login()scan_good()add_good_to_shopping_car()generator_order()pay()with allure.step("斷言"):assert 1if __name__ == '__main__':pytest.main(['-s', 'test_allure_step.py'])

執(zhí)行命令:

> pytest test_allure_step.py --alluredir=./report/result_data> allure serve ./report/result_data

查看測試報告展示效果:

image

從報告中可以看到,我們事先通過@allure.step()定義好的步驟都展示在測試用例test_buy_good()下了。

@allure.step支持嵌套,step中調(diào)用step

# file_name: steps.pyimport allure@allure.step
def passing_step_02():print("執(zhí)行步驟02")pass

測試用例:

# file_name: test_allure_step_nested.pyimport pytest
import allurefrom .steps import passing_step_02  # 從外部模塊中導(dǎo)入@allure.step
def passing_step_01():print("執(zhí)行步驟01")pass@allure.step
def step_with_nested_steps():"""這個步驟中調(diào)用nested_step():return:"""nested_step()@allure.step
def nested_step_with_arguments(arg1, arg2):pass@allure.step
def nested_step():"""這個步驟中調(diào)用nested_step_with_arguments(),并且傳遞參數(shù):return:"""nested_step_with_arguments(1, 'abc')def test_with_imported_step():"""測試@allure.step()支持調(diào)用從外部模塊導(dǎo)入的step:return:"""passing_step_01()passing_step_02()def test_with_nested_steps():"""測試@allure.step()支持嵌套調(diào)用step:return:"""passing_step_01()step_with_nested_steps()passing_step_02()if __name__ == '__main__':pytest.main(['-s', 'test_allure_step_nested.py'])

執(zhí)行命令:

pytest test_allure_step_nested.py --alluredir=./report/result_dataallure serve ./report/result_data

查看測試報告展示效果:

image

從上面的結(jié)果中可以看到:

  • @step可以先保存到其他模塊中,在測試用例中需要用到的時候?qū)刖涂梢粤?#xff1b;
  • @step也支持在一個step中嵌套調(diào)用其他的step;嵌套的形式在測試報告中以樹形展示出來了;

@allure.step支持添加描述且通過占位符傳遞參數(shù)

# file_name: test_allure_step_with_placeholder.pyimport pytest
import allure@allure.step('這是一個帶描述語的step,并且通過占位符傳遞參數(shù):positional = "{0}",keyword = "{key}"')
def step_title_with_placeholder(arg1, key=None):passdef test_step_with_placeholder():step_title_with_placeholder(1, key="something")step_title_with_placeholder(2)step_title_with_placeholder(3, key="anything")if __name__ == '__main__':pytest.main(['-s', 'test_allure_step_with_placeholder.py'])

執(zhí)行命令:

pytest test_allure_step_with_placeholder.py --alluredir=./report/result_dataallure serve ./report/result_data

查看測試報告展示效果:

image

從上面的執(zhí)行結(jié)果中可以看到,@allure.step()是支持輸入描述的,并且支持通過占位符向描述中傳遞參數(shù)。

在conftest.py文件中定義@allure.step

conftest.py文件:

# file_name: conftest.pyimport pytest
import allure@pytest.fixture()
def fixture_with_conftest_step():conftest_step()@allure.step("這是一個在conftest.py文件中的step")
def conftest_step():pass

測試用例:

# file_name: test_allure_step_in_fixture_from_conftest.pyimport pytest
import allure@allure.step
def passed_step():passdef test_with_step_in_fixture_from_conftest(fixture_with_conftest_step):passed_step()if __name__ == '__main__':pytest.main(['-s', 'test_allure_step_in_fixture_from_conftest.py'])

執(zhí)行命令:

pytest test_allure_step_in_fixture_from_conftest.py --alluredir=./report/result_dataallure serve ./report/result_data

查看測試報告展示效果:

從運行結(jié)果中可以看到,在fixture中定義的step會在setup和teardown單獨以樹形結(jié)構(gòu)展示出來。

這可能是B站最詳細(xì)的pytest自動化測試框架教程,整整100小時,全程實戰(zhàn)!!!

http://m.aloenet.com.cn/news/45458.html

相關(guān)文章:

  • 教務(wù)系統(tǒng)網(wǎng)站怎么做南寧網(wǎng)站seo外包
  • 中企動力制作的網(wǎng)站后臺怎樣搭建自己的網(wǎng)站
  • 做網(wǎng)站一個月30ip網(wǎng)絡(luò)推廣是網(wǎng)絡(luò)營銷的基礎(chǔ)
  • 做cpa能用什么網(wǎng)站seo怎么優(yōu)化簡述
  • 怎么創(chuàng)建網(wǎng)站論壇重慶seo公司
  • 網(wǎng)站建設(shè)企業(yè)的未來發(fā)展計劃十大少兒編程教育品牌
  • 網(wǎng)頁設(shè)計代碼模板海賊王網(wǎng)站優(yōu)化排名提升
  • 牛商網(wǎng)營銷型網(wǎng)站建設(shè)廈門百度廣告開戶
  • 網(wǎng)站建設(shè)免費教程我是seo關(guān)鍵詞
  • 佛山建網(wǎng)站建網(wǎng)站找哪個公司
  • 業(yè)余學(xué)做衣服上哪個網(wǎng)站軟文網(wǎng)站大全
  • 廈門國外網(wǎng)站建設(shè)公司排名下載百度app最新版到桌面
  • 微信商城怎么進(jìn)鎮(zhèn)江交叉口優(yōu)化
  • 大連模板網(wǎng)站制作公司廣州網(wǎng)絡(luò)推廣外包
  • 上海最新傳染病疫情今天在線seo外鏈工具
  • 哪個網(wǎng)站可以做練習(xí)題百度收錄排名
  • 零售網(wǎng)站有哪些平臺信息流廣告代理商排名
  • 東莞網(wǎng)站seo推廣優(yōu)化網(wǎng)站統(tǒng)計哪個好用
  • 南陽網(wǎng)站公司簡短的軟文范例
  • 用bootstrap基礎(chǔ)教程做的網(wǎng)站百度熱詞指數(shù)
  • html5農(nóng)業(yè)網(wǎng)站模板搜索引擎營銷的手段包括
  • 簡述網(wǎng)站的創(chuàng)建流程百度推廣工具有哪些
  • 網(wǎng)站建設(shè)的業(yè)務(wù)流程圖競價推廣sem
  • 南昌網(wǎng)站建設(shè)公務(wù)查詢網(wǎng)站相關(guān)網(wǎng)址
  • 怎么做網(wǎng)站計劃寧波企業(yè)網(wǎng)站seo
  • 凡科做網(wǎng)站友情鏈接怎么做百度seo刷排名網(wǎng)址
  • 網(wǎng)站建設(shè)私單合同seo建站系統(tǒng)
  • 織夢制作手機網(wǎng)站模板泉州關(guān)鍵詞優(yōu)化軟件
  • 獵頭做mapping網(wǎng)站百度關(guān)鍵詞查詢排名
  • 做文件的網(wǎng)站手機免費建站系統(tǒng)