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


相关推荐
biter down3 小时前
9:JSONSchema
python
日晨难再3 小时前
C语言&Python&Bash&Tcl:全局变量和局部变量
c语言·python·bash·tcl
麻雀飞吧3 小时前
期货量化主连和具体合约怎么切:天勤 KQ.m 与 KQ.i 用法
python·区块链
先吃饱再说3 小时前
Python List 切片与 LLM Prompt 设计:从数据结构到接口调用
python
一只专注api接口开发的技术猿4 小时前
OpenClaw 对接淘宝商品 API,低成本实现全天候选品监控|附可运行 Python 实操代码
大数据·开发语言·数据库·python
xingpanvip4 小时前
星盘接口开发文档:马盘次限盘接口指南
android·开发语言·python·php·lua
FBI HackerHarry浩4 小时前
第二阶段Day07【Python生成器、yield关键字、property、正则表达式】
开发语言·python·正则表达式
梦想不只是梦与想4 小时前
Python 中的 4 种作用域
python·作用域
coderwei1234 小时前
从OpenAI到Strip:用六大支柱读懂Harness Engineering的生产实践
python·ai·ai编程
海鸥-w4 小时前
Python(FastAPI)中ORM框架Sqlalchemy的安装及建表
python