天天看點

python 自動化測試架構unittest與pytest的差別

前言:

有使用過unittest單元測試架構,再使用pytest單元測試架構,就可以明顯感覺到pytest比unittest真的簡潔、友善很多。

unittest與pytest的差別:

主要從用例編寫規則、用例的前置和後置、參數化、斷言、用例執行、失敗重運作和報告這幾個方面比較unittest和pytest的差別

python 自動化測試架構unittest與pytest的差別
python 自動化測試架構unittest與pytest的差別
python 自動化測試架構unittest與pytest的差別

參數化的差別:

unittest參數化:結合裝飾器ddt來實作

pytest參數化:直接使用@pytest.mark.parametrize(自定義指令參數名稱,資料源)