1. 程式人生 > 其它 >Pytest allure 生成測試報告

Pytest allure 生成測試報告

1、之前用到 Pytest 中的外掛 --html 生成報告,今天我們看下 Pytest 結合 allure 的使用

import pytest
import os

class TestDemo():
    def test_01(self):
        assert 1 == 1

    def test_02(self):
        assert 1 == 0

    def test_03(self):
        print("hello world")

if __name__ == '__main__':
    pytest.main(["-s", "./test_demo1.py
", "--alluredir=./result", "--clean-alluredir"]) """ --alluredir=./result --> 指定執行後生成 json 格式的結果檔案目錄 --clean-alluredir --> 指定每次執行後情況 json 檔案目錄,防止檔案累積 """ os.system("allure generate ./result -c -o ./report") """ allure generate --> allure 生成報告的命令,固定寫法 ./result --> 獲取報告資料的 json 檔案目錄 -c --> 每次執行後清空報告目錄 -o --> 輸出報告命令 ./report --> 報告存放目錄
"""