Pytes及Allure常用命令

pytest常用命令:

pytest --help:查看幫助文檔,當不記得命令時,使用此命令即可,常用

參數:-s

運行過程中執行print打印函數:pytest -s

參數: --collect-only 或 --co

收集將要執行的用例,但不會執行用例:pytest --collcet-onty,可以使用這個參數查看一下命令是否正確,是否能夠收集到指定的測試用例

參數:-k args(可以是py文件名,也可以是函數名)

運行包含關鍵詞的用例:pytest -k change,如圖:

參數:-v / --verbose 或 -q / --quiet

打印用例執行的詳細或簡略過程,pytest -v ,pytest -q

參數:pytest --html=path

生成簡易html報告,path是存儲報告的路徑。

 

參數:--alluredir=DIR 和 --clean-alluredir

--alluredir=DIR:在指定目錄DIR生成allure報告

--clean-alluredir:清除alluredir如果目錄存在的化

一般結合 --alluredir=DIR 命令一起使用 pytest --alluredir=./report/html --clean-alluredir

 

參數:-x

用例運行失敗則立即停止執行

參數:--maxfail=num

用例運行時 允許的最大失敗次數,超過則立即停止,pytest --maxfail=3

 

參數:-m 'mark1 and not mark2'

--markers 顯示所有mark標記

用例運行帶有mark1標記的並且不運行mark2標記的

參數:--tb=選項(選項:'auto', 'long', 'short', 'no', 'line', 'native')

用例運行失敗時,展示錯誤的詳細程度

參數:-l 或--showlocals

用例運行失敗時,打印相關的局部變量,pytest -l

參數:--lf, --last-failed

只執行上次執行失敗的測試

參數:--ff, --failed-first

先執行完上次失敗的測試後,再執行上次正常的測試

參數:運行指定的函數(使用兩對冒號 : 分隔)

pytest 模塊名::類名::函數名,pytest test.py::check_ui

 

Allure命令:

commond: generate

生成allure報告

示例:allure generate ./report/xlm -o ./report/html -c ./report/html

參數:-c, --clean

在生成新的Allure報告之前,先清除該目錄

參數: -o, --report-dir, --output

指定目錄生成allure報告

 

 

commond:open

打開生成的報告,本地查看

示例:allure open ./report/html

參數:-h, --host

指定域名地址

參數:-p, --port

指定端口號

 

commond:serve

打開生成的報告,可對外提供在線展示

示例:allure serve./report/html

參數:-h, --host

指定域名地址

參數:-p, --port

指定端口號

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章