zoukankan      html  css  js  c++  java
  • 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/
    ------------------------------------------------------------------------------------------------------------------------

     

  • 相关阅读:
    nginx负载均衡
    saltstack高效运维
    nginx入门与实战
    web service基础知识
    centos tomcat解压版安装
    centos yum 安装jdk1.7
    centos7安装opencv3.4.1(同样适用于最新版本4.2.0)
    正向代理与反向代理,正向代理与反向代理的应用
    MySQL日期 字符串 时间戳互转
    idea svn提交时,performing vcs refresh时间很长的解决办法
  • 原文地址:https://www.cnblogs.com/peiminer/p/9915708.html
Copyright © 2011-2022 走看看