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

 
原文地址:https://www.cnblogs.com/zhaocbbb/p/12840679.html