一、Allure簡介
Allure是一款非常輕量級並且非常靈活的開源測試報告生成框架。它支持絕大多數測試框架,例如TestNG、Pytest、JUint等。它簡單易用,易於集成。下面就Pytest如何與Allure集成做詳細介紹。
二、配置環境
1.安裝pytest
pip3 install pytest
pip3 install allure-pytest
2.安裝allure
https://dl.bintray.com/qameta/generic/io/qameta/allure/allure/2.7.0/allure-2.7.0.zip
3.配置allure的環境變量
4.查看allure是否安裝成功
allure --version
5.新建demo
import allure import pytest @allure.feature('測試用例1') def test_case_01(): assert 0 @allure.feature('測試用例2') def test_case_02(): assert 0 == 0 if __name__=='__main__': pytest.main(['-s','-q','--alluredir','./report/xml'])
6.生成測試報告
pytest xxx.py --alluredir [xml_path]
allure generate [xml_path] -o [report_path]
參考文章:https://www.jianshu.com/p/109e30c05dec