服務(wù)好的網(wǎng)站制作鄭州seo排名優(yōu)化
-x 用例一旦失敗或錯(cuò)誤時(shí)就立即停止執(zhí)行
共兩條用例,運(yùn)行第一條報(bào)錯(cuò)失敗或報(bào)錯(cuò),第二條就不會(huì)執(zhí)行
pytest -vs -x test_pytest_study.py::TestCommon1? ? ? ? ? ??
共2條用例,當(dāng)執(zhí)行到第一條失敗時(shí)候,第二條不執(zhí)行
?
--maxfail=num
當(dāng)用例錯(cuò)誤個(gè)數(shù)達(dá)到指定數(shù)量時(shí),停止測(cè)試
pytest -vs --maxfail=2 test_pytest_study.py::TestCommon1? ? ? ? ? ??
共3條用例,當(dāng)執(zhí)行到第一條和第二條都失敗時(shí)候,第三條不執(zhí)行
-k 用例方法關(guān)鍵字匹配
會(huì)根據(jù)模塊模塊名稱(chēng)、類(lèi)名稱(chēng)、方法名稱(chēng)進(jìn)行匹配? 比如只想運(yùn)行模塊中包含關(guān)鍵字類(lèi)中包含關(guān)鍵字login? 或 方法包含關(guān)鍵字login? ?pytest -vs -k login testcases/test_pytest_study.py
那么模塊中的函數(shù)名稱(chēng)存在:login 會(huì)執(zhí)行
模塊中類(lèi)名稱(chēng)存在:login 不區(qū)分大小寫(xiě); 里面的所有用例會(huì)執(zhí)行
模塊類(lèi)名稱(chēng)不包含login 但里面的方法名稱(chēng)包含login 也會(huì)執(zhí)行
-v 打印詳細(xì)日志? -s 打印輸出日志 一般都一起使用 -vs
--collect-only 只收集用例,不執(zhí)行用例
--help 其他參數(shù)可使用幫助命令查看
--reruns num 失敗重跑 (需安裝pytest-rerunfailures 插件)
安裝插件:pip install??pytest-rerunfailures
pytest -vs --reruns 2 test_login.py? 失敗了重跑2次
?
--html 生成html 報(bào)告(需安裝pytest-html 插件)
pytest test_login.py --html ./reports/result.html
?
?