首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >Python + allure 报告[通俗易懂]

Python + allure 报告[通俗易懂]

作者头像
全栈程序员站长
发布2022-09-17 10:44:30
发布2022-09-17 10:44:30
1.2K0
举报

大家好,又见面了,我是你们的朋友全栈君。

安装

Windows安装allure需要先安装scoop,确保安装了PowerShell 5(或更高版本,包括PowerShell Core)和. net Framework 4.5(或更高版本)。然后打开PowerShell运行: iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

安装allure:scoop install allure

貌似国内没有梯子的后来这种安装方式不行了,一直安装scoop失败,特意加了手动安装的方法

手动安装
  • Maven Central 下载最新的版本的压缩包
  • 解压缩,定位到bin目录下
  • 将该路径添加到环境变量PATH
安装pytest-allure插件,运行:pip install allure-pytest
使用

运行测试用例:pytest --alluredir=/tmp/my_allure_results 直接打开测试报告:allure serve /tmp/my_allure_results 将会在默认浏览器中打开测试报告:

或者生成测试报告:allure generate /tmp/my_allure_results -o /tmp/report --clean 打开测试报告:allure open -h 127.0.0.1 -p 8083 /tmp/report 目前allure2暂不支持allure.environment(platform_name=‘Android’)这种方法设置环境注解,不过在生成报告之前,可以通过把environment.properties (or environment.xml) 文件放到生成的allure-results文件夹下来添加(参考:Environment)。 environment.properties

代码语言:javascript
复制
Browser=Chrome
Browser.Version=63.0
Stand=Production

environment.xml

代码语言:javascript
复制
<environment>
    <parameter>
        <key>Browser</key>
        <value>Chrome</value>
    </parameter>
    <parameter>
        <key>Browser.Version</key>
        <value>63.0</value>
    </parameter>
    <parameter>
        <key>Stand</key>
        <value>Production</value>
    </parameter>
</environment>
集成jenkins

安装 Allure Plugin插件,jenkins的Manage Jenkins->Manage Plugins->查找Allure Jenkins Plugin并安装

配置command,Manage Jenkins->Global Tool Configuration找到Allure Commandline,点击Allure Commandline installations…,点击保存即可。

创建一个pipline的项目,输入以下脚本:

代码语言:javascript
复制
pipeline {
    agent any
    stages {
        stage('Example') {
            steps {
                echo "hello World!"
                bat 'cd C:\\your-path && pytest --alluredir=result -s -v login_scenario.py'
            }
        }
    }
    post("Report"){
        always{
            script{
                allure includeProperties: false, jdk: '', report: 'report', results: [[path: 'result']]            }
        }
    }
}
参考:
  1. https://docs.qameta.io/allure/#_python
  2. https://testerhome.com/topics/15649
  3. https://github.com/allure-framework/allure-python/tree/master/allure-pytest

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/164430.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 安装
  • 手动安装
    • 安装pytest-allure插件,运行:pip install allure-pytest
  • 使用
  • 集成jenkins
  • 参考:
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档