19-pytest-allure-pytest环境搭建
Posted 爱学习de测试小白
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了19-pytest-allure-pytest环境搭建相关的知识,希望对你有一定的参考价值。
目录
前言
- 使用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:在报告原始文件同级目录执行
以上是关于19-pytest-allure-pytest环境搭建的主要内容,如果未能解决你的问题,请参考以下文章