WEB自动化-Allure报告-Allure安装和简单用法

WEB自动化测试可以借助Allure生成美观的测试报告。

1、安装工具及配置环境变量

  1.安装JDK1.8 才可运行allure,直接百度,一大堆
  2.下载Allure的安装包(版本号:2.13.5)
  https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/
  3.解压Allure压缩包
  4.配置Allure到环境变量,到path里面,D:\allure-2.13.5\bin
  

 

  打开cmd, 验证: allure --version

2、安装allure-pytest

allure测试报告是基于pytest运行的,运行之后生成一个json报告数据源,来实现结果
的展示,以一个工程的形态展示本次测试的所有测试结果
需要集成pytest实现allure的展示,需要安装:
pip install allure-pytest
验证:pip show allure-pytest 
 
PS:allure报告生成之后,要发给别人,必须发送report的整个文件夹,并且要用pycharm
才能打开
 
验证:
创建测试用例文件,弄几个简单的例子
def test01():
    print("1")


class TestDemo:
    def test02(self):
        print("2")


class TestDemo1:
    def test03(self):
        print("3")


def test04():
    print("4")

再创建main文件执行用例

import os    # 导入操作系统包,接口和系统之间交换数据

import pytest


def run():
    # pytest.main(['-s'])
    pytest.main(['--alluredir', './result', '--clean-alluredir'])
    # --clean-alluredir是为了清除上次的记录,以免显示报告是上次的
    os.system('allure generate ./result/ -o ./report/ --clean')
    # 这里的clean也是为了清除上次的报告


if __name__ == '__main__':
    run()

在生成的report目录下找到index.html文件,打开可显示报告

 

 

posted @ 2023-08-10 20:44  琉璃星眸  阅读(191)  评论(0编辑  收藏  举报