服務(wù)好的網(wǎng)站制作鄭州seo排名優(yōu)化
-x 用例一旦失敗或錯誤時就立即停止執(zhí)行
共兩條用例,運行第一條報錯失敗或報錯,第二條就不會執(zhí)行
pytest -vs -x test_pytest_study.py::TestCommon1? ? ? ? ? ??
共2條用例,當執(zhí)行到第一條失敗時候,第二條不執(zhí)行
?
--maxfail=num
當用例錯誤個數(shù)達到指定數(shù)量時,停止測試
pytest -vs --maxfail=2 test_pytest_study.py::TestCommon1? ? ? ? ? ??
共3條用例,當執(zhí)行到第一條和第二條都失敗時候,第三條不執(zhí)行
-k 用例方法關(guān)鍵字匹配
會根據(jù)模塊模塊名稱、類名稱、方法名稱進行匹配? 比如只想運行模塊中包含關(guān)鍵字類中包含關(guān)鍵字login? 或 方法包含關(guān)鍵字login? ?pytest -vs -k login testcases/test_pytest_study.py
那么模塊中的函數(shù)名稱存在:login 會執(zhí)行
模塊中類名稱存在:login 不區(qū)分大小寫; 里面的所有用例會執(zhí)行
模塊類名稱不包含login 但里面的方法名稱包含login 也會執(zhí)行
-v 打印詳細日志? -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 報告(需安裝pytest-html 插件)
pytest test_login.py --html ./reports/result.html
?
?