美文网首页
allure-05-生成html报告

allure-05-生成html报告

作者: 果芽软件 | 来源:发表于2019-07-14 12:09 被阅读0次

一、根据xml生成html报告

方式一(命令行):

allure generate ./reports/xml -o ./reports/html --clean
字段 含义
allure 调用allure程序
generate 生成报告
./reports/xml 报告的xml数据源路径
-o 参数名,后面跟html报告存储路径
./reports/html 参数值,指定html报告存储路径

方式二(代码):

  1. allure没提供pytest一样的main方法
  2. 需要先写cmd命令
  3. 再调用标准库执行cmd命令
  4. 此处的
from tools import log_tool
from tools import Shell
import pytest

if __name__ == '__main__':
    # 自定义log工具
    log = log_tool.MyLog()

    xml_report_path = './reports/xml/'
    html_report_path = './reports/html/'

    pytest.main(['-s', '-q', '--alluredir',
                 xml_report_path,'./test_case/test_user.py'])

  # 自定义shell工具
    shell = Shell.Shell()
    cmd = "allure generate %s -o %s --clean"%(xml_report_path,html_report_path)
  
    try:
        shell.invoke(cmd)
    except Exception:
        log.error('执行用例失败,请检查环境配置')
        raise

二、查看html报告

1. 找到html报告路径

image.png

2. 打开index.html

image.png

3. 浏览器打开

image.png

4. 设置成中文

image.png

相关文章

网友评论

      本文标题:allure-05-生成html报告

      本文链接:https://www.haomeiwen.com/subject/tjyskctx.html