Pytest安装Allure生成自动化测试报告

Date: 2025.01.09 16:33:01 author: lijianzhan

Allure 是一个强大的测试报告框架,能够生成美观且详细的测试报告。它与 pytest 结合使用,可以帮助你更好地展示测试结果、分析测试数据,并提高测试的可读性和可维护性。以下是关于如何在 Python 中使用 Allure 的详细指南,包括安装、配置、注解和生成报告。

  1. 安装 Allure
    allure-pytest 是 pytest 的插件,用于生成 Allure 报告,安装命令如下:
bash 复制代码
pip install allure-pytest
  1. 安装 Allure 命令行工具
    Allure 报告需要 Allure 命令行工具来生成和展示,下载地址
    2.1 Windows
    2.2 下载 Allure 命令行工具:Allure 下载页面
    2.3 解压并配置环境变量:
    2.4 将 bin 目录添加到系统的 PATH 环境变量中。

    2.5 macOS
    2.6 使用 Homebrew 安装:
bash 复制代码
brew install allure
  1. 验证安装命令如下:
bash 复制代码
allure --version
  1. 配置 pytest,修改 pytest.ini文件,在项目根目录下创建或修改 pytest.ini 文件,配置 Allure 报告的输出目录
python 复制代码
[pytest]
addopts = -v -s --alluredir=./allure-results
  1. 生成并查看报告,使用 Allure 命令行工具生成并查看报告:
python 复制代码
allure serve ./allure-results


相关推荐
共享家95274 小时前
搭建 AI 聊天机器人:”我的人生我做主“
前端·javascript·css·python·pycharm·html·状态模式
Hgfdsaqwr5 小时前
Python在2024年的主要趋势与发展方向
jvm·数据库·python
一晌小贪欢5 小时前
Python 测试利器:使用 pytest 高效编写和管理单元测试
python·单元测试·pytest·python3·python测试
小文数模5 小时前
2026年美赛数学建模C题完整参考论文(含模型和代码)
python·数学建模·matlab
Halo_tjn5 小时前
基于封装的专项 知识点
java·前端·python·算法
Hgfdsaqwr6 小时前
掌握Python魔法方法(Magic Methods)
jvm·数据库·python
weixin_395448916 小时前
export_onnx.py_0130
pytorch·python·深度学习
s1hiyu6 小时前
使用Scrapy框架构建分布式爬虫
jvm·数据库·python
2301_763472466 小时前
使用Seaborn绘制统计图形:更美更简单
jvm·数据库·python
无垠的广袤6 小时前
【VisionFive 2 Lite 单板计算机】边缘AI视觉应用部署:缺陷检测
linux·人工智能·python·opencv·开发板