资讯 小学 初中 高中 语言 会计职称 学历提升 法考 计算机考试 医护考试 建工考试 教育百科
栏目分类:
子分类:
返回
空麓网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
空麓网 > 计算机考试 > 软件开发 > 后端开发 > Python

allure环境搭建

Python 更新时间: 发布时间: 计算机考试归档 最新发布

allure环境搭建

allure环境搭建

在搭建之前你应该有python、pycharm

allure介绍

  • 官网:Allure Framework

  • 英文介绍

    • Allure Framework is a flexible lightweight multi-language test report tool that not only shows a very concise representation of what have been tested in a neat web report form, but allows everyone participating in the development process to extract maximum of useful information from everyday execution of tests

  • 翻译:

    • allure是一个框架

    • 灵活、轻量、多语言

    • 测试报告

JDK

allure依赖于JAVA,所以你应该有JAVA环境,如果已经配置过可跳过

  • 推荐用JDK 1.8这样的版本

    • 下载链接:JDK8 下载 - 编程宝库

    • 注意自己的操作系统

  • JAVA_HOME和PATH变量的配置(仅供参考)

 

allure-pytest库安装

  • pip安装

     pip  install -i https://mirrors.aliyun.com/pypi/simple allure-pytest 
  • 说明:

    • 你要用allure,你就要有pytest这个库

    • 安装allure-pytest的时候如果没有pytest是会自动安装的,因为他依赖pytest

       pip show allure-pytest ​ Name: allure-pytest Version: 2.9.45 Summary: Allure pytest integration Home-page: https://github.com/allure-framework/allure-python Author: QAMetaSoftware, Stanislav Seliverstov Author-email: sseliverstov@qameta.io License: Apache-2.0 Location: c:python39libsite-packages Requires: allure-python-commons, pytest, six Required-by:
    • 你可以理解为allure-pytest是pytest的一个插件

    • 但跟大多数插件不一样的命名allure-pytest,而普通的插件多是pytest-xxx的形式。

  • 注意事项

    • 如果你是新手,你有多个环境(可能是多个python、或有虚拟环境),那推荐在pycharm中安装,那就简单很多,当然也最好配置要安装仓库。

    • 如果你没有配置pip的源,可以手工加-i参数来指定

       pip install -i https://pypi.tuna.tsinghua.edu.cn/simple  allure-pytest ​ # 类似的源头很多,比如阿里云的 https://mirrors.aliyun.com/pypi/simple

allure应用程序配置

第一步:下载allure应用程序

  • 你下面2个地址任选其一下载即可。

    • maven仓库地址

     https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/
    • github地址

     https://github.com/allure-framework/allure2/releases
  • 选择自己的平台版本(windows你可以下载zip格式,linux就tgz),下载,然后解压到某个目录下(下图是2022年的一个截图,你看的到未必一样)

第二步:将allure所在的目录配置到PATH中去

  • 此处以allure-2.14.0为图例,所有版本都一样的配置方法

     

  • 新开一个cmd,输入命令以验证

     C:Userssongqin008>allure --version 2.14.0

第三步:重启pycharm,确保能读取到更新后的PATH

  • 首次配置需要

  • 其实也可以手工配置PATH

第四步:编写一个测试代码

  • DEMO

     ​ import pytest,os ​ def test_001():     assert 1==1 ​ ​ if __name__ == '__main__':     pytest.main(['-sv',__file__,'--alluredir','./tmp','--clean-alluredir'])     os.system(f'allure serve ./tmp')
  • 控制台输出

     D:Python39python.exe D:/demos/demo_allure.py ============================= test session starts ============================= platform win32 -- Python 3.9.6, pytest-7.1.2, pluggy-1.0.0 -- D:Python39python.exe cachedir: .pytest_cache metadata: {'Python': '3.9.6', 'Platform': 'Windows-10-10.0.19044-SP0', 'Packages': {'pytest': '7.1.2', 'py': '1.11.0', 'pluggy': '1.0.0'}, 'Plugins': {'allure-pytest': '2.9.45', 'anyio': '3.5.0', 'Faker': '13.3.4', 'assume': '2.4.3', 'base-url': '1.4.2', 'dependency': '0.5.1', 'forked': '1.4.0', 'html': '3.1.1', 'instafail': '0.4.2', 'metadata': '1.11.0', 'ordering': '0.6', 'repeat': '0.9.1', 'rerunfailures': '10.2', 'sugar': '0.9.4', 'timeout': '2.1.0', 'xdist': '2.5.0'}, 'JAVA_HOME': 'D:Javajdk1.8.0_301', 'Base URL': ''} rootdir: D:pythonProjectAutoTestAutoHuayan61demos plugins: allure-pytest-2.9.45, anyio-3.5.0, Faker-13.3.4, assume-2.4.3, base-url-1.4.2, dependency-0.5.1, forked-1.4.0, html-3.1.1, instafail-0.4.2, metadata-1.11.0, ordering-0.6, repeat-0.9.1, rerunfailures-10.2, sugar-0.9.4, timeout-2.1.0, xdist-2.5.0 collecting ... collected 1 item ​ demo_allure.py::test_001 PASSED ​ ============================== 1 passed in 0.10s ============================== Generating report to temp directory... Report successfully generated to C:UsersSONGQI~1AppDataLocalTemp4761329703454998013allure-report Starting web server... 2022-08-09 11:42:32.445:INFO::main: Logging initialized @2843ms to org.eclipse.jetty.util.log.StdErrLog Server started at . Press  to exit
  • 会自动打开一个浏览器,界面大致如下,基本就ok了。下面就是学习allure的细节了,此处不表。

转载请注明:文章转载自 http://www.konglu.com/
本文地址:http://www.konglu.com/it/1097208.html
免责声明:

我们致力于保护作者版权,注重分享,被刊用文章【allure环境搭建】因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理,本文部分文字与图片资源来自于网络,转载此文是出于传递更多信息之目的,若有来源标注错误或侵犯了您的合法权益,请立即通知我们,情况属实,我们会第一时间予以删除,并同时向您表示歉意,谢谢!

我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2023 成都空麓科技有限公司

ICP备案号:蜀ICP备2023000828号-2