pytest系列(三) -- allure报告

声明:参考B站视频,自学成长记录
https://www.bilibili.com/video/BV1u5411A7Um?p=12

什么是allure

pytest-html 生成html格式得测试报告
allure-pytest 生成 更美观 得测试报告

下载、配置allure

下载allure

下载地址:
https://github.com/allure-framework/allure2/releases

在这里插入图片描述

解压allure
在这里插入图片描述

配置path

将allure的路径配置到path环境变量中

在这里插入图片描述
验证allure

1、重启pycharm
2、Terminal窗口:allure --version 进行验证
如下图,则表示配置成功

在这里插入图片描述
安装allure-pytest插件

pycharm --> File --> Settings
Project --> Python Interpreter --> +
检索 allure-pytest --> Install Package
在这里插入图片描述
allure-pytest插件未安装,执行pytest时会报:
error: unrecognized arguments: --alluredir

生成allure报告

增加参数

pytest.ini 增加 –alluredir ./tmp 参数,生成json临时文件

[pytest]
addopts = -vs --alluredir ./temp
python_files =  test_*.py  *_test.py
python_classes = Test*
python_functions = test_*
testpaths = ./testcase
markers =
    smoke:冒烟测试
    uat:业务测试

在这里插入图片描述

运行脚本
在这里插入图片描述

运行结果

在项目根目录 自动生成 temp文件 + 对应json文件

在这里插入图片描述
将json文件生成html文件

执行文件中增加:
import os
os.system(‘allure generate ./temp -o ./reports --clean’)

# -*- coding: utf-8 -*-
# @File : pytest-run.py
import os

import pytest

if __name__ == '__main__':
    pytest.main()
    os.system('allure generate ./temp -o ./reports  --clean')
    '''
    allure generate:生成命令
    ./temp:         原json文件目录
    -o:             输出
    ./reports:      新生成的allure的报告
    --clean:        每次生成时 会清空之前./reports生成的报告
    '''

在这里插入图片描述
在这里插入图片描述
查看reports/index.html
在这里插入图片描述
allure报告效果
在这里插入图片描述

  • 2
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值