pytest文件2 用例執行

2022-05-31 01:00:09 字數 378 閱讀 4950

1.檔名以test_******.py檔案和*******_test.py

2.以test_****開頭的函式

3.以test***開頭的類

4.以test_*****開頭的方法

5.所有的包pakege必須要有__init__.py檔案

1.執行目錄下所有的用例:pytest 檔名/

2.執行乙個py檔案下用例:pytest 指令碼名稱.py

3.-x 遇到錯誤時停止測試:pytest -x test.py

4.當用例錯誤個數達到指定數量時,停止測試:pytest —maxfail=10

5.執行.py模組裡面的某個函式:pytest test.py::test_func

Pytest 執行用例

pytest 不止可以執行自己的用例,也可以執行 unittest 寫的用例。pytest 有很多執行時引數,用於指定執行的用例 執行結果展示 外掛程式引數等。pytest 有兩種執行方式 命令列通過 pytest 命令執行 pytest 引數 引數值 中使用pytest.main 引數1 引數值1...

pytest2 用例執行規則

1.檢視pytest命令列引數,可以用pytest h 或pytest help檢視 x 遇到錯誤時停止測試 v 列印出詳情結果 q只顯示結果,不顯示過程 s引數是為了顯示用例的列印資訊 k 按關鍵字匹配 collect only 檢視 哪些用例會被執行 maxfail num 當用例錯誤個數達到指...

pytest執行多個mark用例

import pytest pytest.mark.desktop professional pytest.mark.特性1 def test 1 print 執行了桌面專業版特性1用例 assert true pytest.mark.desktop professional pytest.mark...