19-pytest-allure-pytest环境搭建

目录

前言

安装alluer

安装allure命令行工具

代码示例

查看报告


前言

  • 使用pytest跑完了用例,还要有个漂亮的报告展示出自动化case的结果,现在一起来学习下alluer吧

安装alluer

# 直接安装
pip install pytes

# 豆瓣镜像安装,速度快
pip3 install allure-pytest -i http://pypi.douban.com/simple/

安装allure命令行工具

  •  配置环境变量:先解压,把bin路径添加到环境变量

代码示例

# -*- coding: utf-8 -*-
# @Time    : 2021/11/6
# @Author  : 大海
# @File    : test_37.py

import os
import allure

@allure.step("步骤1:点击首页")
def test_step_1():
    print("点击首页")


@allure.step("步骤2:点击banner")
def test_step_2():
    print("点击banner")


if __name__ == '__main__':
    # alluredir 是存放allure报告信息的目录
    os.system('pytest -s test_37.py --alluredir ./report/allure_raw')
  • 执行完在当前目录下生成了报告的原始json文件

查看报告

  •  allure serve report/allure_raw:在报告原始文件同级目录执行

 

猜你喜欢

转载自blog.csdn.net/IT_heima/article/details/121301253