pytest allure報告最適合的版本教程

2022-04-28 19:03:07 字數 1195 閱讀 2129

一、環境:

1、python3

2、pytest (一定別選最新的,4.0.2親測可用,否則會跳到坑二;還有專案名千萬別以pytest開頭)

二、準備**

import pytest

# 不帶引數是預設scope='function'

@pytest.fixture()

def login():

print('輸入賬號和密碼')

def test_01(login):

print('test1----')

def test_02():

print('test2----不登入')

def test_03(login):

print('test3----')

if __name__ == '__main__':

pytest.main(['-s', 'test_001.py'])

三、執行(cmd)

1、切到**所在目錄下:(dir看得見就可以)

py.test --alluredir=reports(成功執行後,會在case所在目錄下生成reports檔案,裡面有檔案ok)

2.生成html

allure generate reports(會在case所在目錄生成資料夾,進入開啟index.html--記得用火狐哦,谷歌是loading和404,哈哈哈哈)

新增用例後,更新allure-reports:

allure generate reports --clean

備註:報告的生成路徑,也可以自定義

乙個報告弄了2次,再次感謝前輩的踩坑記錄,我才能填坑成功;記錄下,萬一換個電腦呢---

坑一)坑二)

pytest allure測試報告

該型別的警告大多屬於版本更新時,所使用的方法過時的原因,可以在該方法的說明出查詢替換的方法 1 安裝allure c 驗證allure環境配置成功 命令列cmd,輸入allure 2 pytest安裝外掛程式 pip install allure pytest3 pytest生成allure測試報告...

Pytest allure測試報告

解壓到非中文目錄下 然後設定環境變數 將allure bin目錄新增到path變數 重新開啟cmd,執行allure version 安裝allure pytest外掛程式 pip install allure pytest 2.報告生成 建立專案或者包 建立指令碼檔案test allure.py ...

pytest allure生成測試報告

allure 報告樣式美觀 首先要安裝allure 安裝模組 pip install allure pytest 生成測試報告 alluredir 報告的路徑 注意 這樣只能生成json的資料檔案 還需要在cmd 裡面渲染成html格式的檔案 allure generate clean 生成的xml...