python-pytest+Allure環境搭建


一、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

 


免責聲明!

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



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