1. pytest-html
安裝:
pip install pytest-html # 通過pip安裝pytest-html
運行測試文件的時候,命令行加上對應參數即可
比如:pytest test_class.py --html=./report.html, (./report.html表示在當前目錄下,創建名稱叫report的html文件)
效果大概就是醬紫的
2. pytest-rerunfailures
安裝:
pip install pytest-rerunfailures #通過pip安裝pytest-rerunfailures
運行測試文件 pytest test_class.py --reruns 5 (失敗重跑5次)
3. pytest-ordering
pytest-ordering(pytest不像unittest那樣,自帶可以自由組合suit,所以需要借助第三方插件)
安裝:
pip install pytest-ordering
https://pypi.org/project/pytest-ordering/
https://pytest-ordering.readthedocs.io/en/develop/
使用展示:運行順序會從下到上依次執行,用起來也感覺也比unittest組裝suit要簡潔點(純屬個人觀點,錯了表打我)
執行測試: