Pytest-html
1、安裝命令pip3 install pytest-html,如下圖:

執⾏后,會在當前⽬錄下⽣成 ⼀個report.html的⽂件,打開后會展示詳細的測試報告,執行該命令python -m pytest tests/ --html=report/index.html
將會在report文件夾下生成index.html報告。
2、pytest-rerunfailures
對執行失敗的再次執行。安裝命令pip3 install pytest-rerunfailures,安裝如下圖:

3、pip3 install -U pytest升級版本
為了是測試報告看起來更加的舒適,我們需要安裝allure-2.7.0,將解壓好的allure-2.7.0文件夾(解壓后里面有兩個文件夾)下的bin打開,復制路徑,
在此電腦的屬性中選擇高級系統設置配置環境變量,再選擇Administrator的用戶變量下選擇Path,將文件路徑粘貼。
在cmd中執行allure檢測安裝是否成功,如圖安裝成功

再執行以下命令:
python -m pytest tests --alluredir=report/result(result下生成json的文件)
allure generate report/result/ -o report/html --clean (report下生成html的目錄,里面包含了html的測試報告)
allure serve report/result(啟動allure的服務,自動打開測試報告)
將會生成一個完美的測試報告,如下圖:

