pytest -- 测试报告allure

pytest -- 测试报告allure

官⽅⽂档:https://allurereport.org/docs/pytest-configuration

介绍

Allure Report 由⼀个框架适配器和 allure 命令⾏⼯具组成,是⼀个流⾏的开源⼯具,⽤于可视化测试运⾏的结果。它可以以很少甚⾄零配置的⽅式添加到您的测试⼯作流中。它⽣成的报告可以在任何地⽅打开,并且任何⼈都可以阅读,⽆需深厚的技术知识

安装

下载allure-pytest包

python 复制代码
pip install allure-pytest==2.13.5

下载Windows版Allure报告

下载压缩包

下载链接:https://github.com/allure-framework/allure2/releases/download/2.30.0/allure-2.30.0.zip

添加系统环境变量

将allure-2.29.0对应bin⽬录添加到系统环境变量中

确认结果

打开cmd,查看allure版本

出现 allure 版本则安装成功。

💡 若出现cmd中执⾏ allure --version 可以打印版本,但是pycharm控制台执⾏命令提⽰命题找不到,则需要修改pycharm中命令⾏环境,如下:

保存后需要重启pycharm!!!!!!

检查pycharm中命令⾏是否可以使⽤allure命令

使⽤

step1:运⾏⾃动化,并指定测试报告放置路径

python 复制代码
pytest --alluredir=results_dir(保存测试报告的路径)
⽰例:pytest --alluredir=allure-results

step2:查看测试报告

1)⽅法⼀:启动⼀个本地服务器来在浏览器中展⽰测试报告

终端执⾏命令: allure serve [options] ,⾃动在浏览器打开测试报告

• --host :指定服务器监听的主机地址,默认为 localhost。

• --port :指定服务器监听的端⼝号,默认为 0(⾃动选择空闲端⼝)

• --clean-alluredir :清除上⼀次⽣成的测试报告

⽰例:

python 复制代码
#不指定端⼝号和主机地址
allure serve .\allure-results\
#指定端⼝号
allure serve --port 8787 .\allure-results\

2)⽅法⼆:从测试结果⽣成测试报告

终端执⾏命令: allure generate [options] -o

⽰例:

python 复制代码
allure generate .\allure-results\ -o .\allure-report --clean
python 复制代码
allure generate .\allure-results\ -o .\allure-report --clean
相关推荐
姚青&3 天前
Pytest 测试用例编写
测试用例·pytest
Warren983 天前
Pytest Fixture 作用域与接口测试 Token 污染问题实战解析
功能测试·面试·单元测试·集成测试·pytest·postman·模块测试
serve the people4 天前
python环境搭建 (七) pytest、pytest-asyncio、pytest-cov 试生态的核心组合
开发语言·python·pytest
真智AI5 天前
用 LLM 辅助生成可跑的 Python 单元测试:pytest + coverage 覆盖率报告(含运行指令与排坑)
python·单元测试·pytest
Warren985 天前
Allure 常用装饰器:实战用法 + 最佳实践(接口自动化)
运维·服务器·git·python·单元测试·自动化·pytest
Warren986 天前
Pytest Fixture 到底该用 return 还是 yield?
数据库·oracle·面试·职场和发展·单元测试·pytest·pyqt
Warren987 天前
Pytest Fixture 作用域详解:Function、Class、Module、Session 怎么选
面试·职场和发展·单元测试·pytest·pip·模块测试·jira
我的xiaodoujiao8 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 44--将自动化测试结果自动推送至钉钉工作群聊
前端·python·测试工具·ui·pytest
我的xiaodoujiao8 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 45--生成项目需要的requirements.txt依赖文件
python·学习·测试工具·pytest
月明长歌8 天前
全栈测试修炼指南:从接口策略到 Python+Pytest+Allure 企业级架构
python·架构·pytest