【pytest】(七) pytest的一些你愛不釋手的插件


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要簡潔點(純屬個人觀點,錯了表打我)

執行測試:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM