• pytest 11 allure2生成html报告


    allure是一个report框架,支持java的Junit/testng等框架,当然也可以支持python的pytest框架,也可以集成到Jenkins上展示高大上的报告界面。

    环境准备

    • 1.python3.6

    • 2.mac环境

    • 3.pycharm

    • 4.pytest-allure-adaptor

    • 5.allure2.8.0

    • 6.java1.8或者1.8以上

    Allure Pytest Adaptor是Pytest的一个插件,通过它我们可以生成Allure所需要的用于生成测试报告的数据。安装pytest-allure-adaptor插件方法

    1.下载和安装命令: 

    pip3 install pytest-allure-adaptor

    首先需要安装命令行工具,如果是Mac电脑,推荐使用Homebrew安装。

    $ brew install allure

    2.生成xml报告:

    pytest -s -q —alluredir report

    如果不指定路径,默认在当前目录下新建一个report目录,当然也可以指定路径   ($ pytest -s -1q --alluredir ./result/

    pytest -s -q —alluredir 指定report路径

    执行完之后打开report文件夹,会自动生成xml格式的报告

    我的在 /Users/newcomer/gitByMyself/python_work_apple/pytest_package/demo 目录下执行的

    首先:

    cd /Users/newcomer/gitByMyself/python_work_apple/pytest_package/demo

    然后:

    pytest -s -q --alluredir report

    这一步已经生产了xml格式的报告,放到了report目录下:

    3.运行allure2

    按照这样的格式:allure generate directory-with-results/ -o directory-with-report。directory-with-results是alluredir生成的xml目录,directory-with-report是最终生成html的目录(allure generate ./result/ -o ./report/ --clean),可以用相对路径去生成html报告

    allure generate report/ -o report/html --clean

    这样在./report/目录下就生成了Allure的测试报告了。–clean目的是先清空测试报告目录,再生成新的测试报告。打开的时候在pycharm里面打开,这样的页面就不会是空的了

    第一个report(因为设置的目录名字叫report)是alluredir生成的xml目录,第二个report是最终生成html的目录

    还可以通过下面的命令打开测试报告:

    --------------------------------------------------------------------------------------------------------

    $ allure open -h 127.0.0.1 -p 8083 ./report/
    ------------------------------------------------------------------------------------------------------------------------

     

  • 相关阅读:
    在监控落地的路上,助你一臂之力
    一文讲透数据结构中的树,建议收藏!
    别人家的 InfluxDB 实战 + 源码剖析
    从 React 架构开始讲解 useState、useEffect 编程设计
    事件捕获、事件冒泡、事件委托
    JavaScript设计模式学习笔记
    复制到剪贴板,粘贴进微信,换行符失效
    curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
    nodejs版本管理工具n教程
    手把手教你撸一套Redux(Redux源码解读)
  • 原文地址:https://www.cnblogs.com/peiminer/p/9915708.html
Copyright © 2020-2023  润新知