pytest使用allure生成测试报告

2019-12-23  本文已影响0人  WeiFong

环境准备:

安装python插件:
allure工具安装:
  • 前置条件:
    已部署java环境
  • 解压并配置系统环境变量(以下是mac的)
breeze$ vim .bash_profile

allure报告动态属性

# sheet名称 feature 一级标签
allure.dynamic.feature(sheet_name)
# 模块 story 二级标签
allure.dynamic.story(case_model)
# 用例ID+接口名称 title
allure.dynamic.title(case_id+case_name)
# 请求URL 请求类型 期望结果 实际结果描述
desc = "<font color='red'>请求URL:</font>{}<Br/>" \
           "<font color='red'>请求类型:</font>{}<Br/>" \
           "<font color='red'>期望结果:</font>{}<Br/>" \
           "<font color='red'>实际结果描述:</font>{}<Br/>".format(url,method,expect,expect_result)
allure.dynamic.description(desc)

生成xml报告

pytest -s -q --alluredir ./report/result_allure

生成html报告(前提:必需先生成xml报告)

allure generate report/result_allure -o report/allure_html

subprocess执行cmd

subprocess.call("ls -l",shell=True)
subprocess.call("allure generate report/result_allure -o report/allure_html",shell=True)
上一篇 下一篇

猜你喜欢

热点阅读