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
相关推荐
我的xiaodoujiao1 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 28--开源电商商城系统项目实战--封装注册页面
python·学习·测试工具·pytest
Mr_Xuhhh2 天前
pytest -- fixture
开发语言·python·pytest
Mr_Xuhhh2 天前
pytest -- 指定⽤例执⾏顺序
开发语言·python·pytest
Mr_Xuhhh2 天前
pytest -- ⽇志与测试报告
pytest
西游音月4 天前
(5)pytest+Selenium自动化测试-元素定位之XPath定位
selenium·测试工具·pytest
西游音月6 天前
(4)pytest+Selenium自动化测试-元素定位之CSS Selector定位
css·selenium·pytest
淼_@淼7 天前
pytest-数据驱动
pytest
我的xiaodoujiao8 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 27--二次封装方法--优化断言结果
python·学习·测试工具·pytest
淼_@淼10 天前
pytest简介
运维·服务器·pytest