pytest(12): Allure安装

allure介绍

  • allure是一个轻量级,灵活的,支持多语言的测试报告工具,pytest,JS ,php,ruby
  • 多平台的奢华的report框架
  • 可以为DEV/QA提供详尽的测试报告,测试步骤,log.
  • 可以集成到Jenkins

allure使用官方文档地址:http://allure.qatools.ru/

allure安装

1.zip包下载安装:

下载地址:https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/(最新日期的就是最新的包)

2.github下载安装

下载地址:https://github.com/allure-framework/allure2/releases

 下载完成之后,解压到本地磁盘,找到bin目录

 path环境变量配置

 配置完成之后查看allure的版本

用例演示

test.py 测试demo

import pytest
import allure

@allure.feature('测试模块')
class  TestDemo:

    @allure.story('测试功能')
    def test_one(self):

        with allure.step('登录成功'):
            print("登录账号")
        with allure.step("点击商品"):
            print("点击商品,购买")
        with allure.step('购买商品'):
            print("商品购买完成")

使用allure方式运行,cd到所在脚本路径执行下面的命令

 pytest test.py --alluredir ./report/allure_raw 

report目录如不不存在的话,会自从生成后面也可以继续增加目录,如果增加日期:pytest test.py  --alluredir ./report/20201014/allure_raw

运行结果:

 因为allure页面打开是需要渲染的,所以不能直接右键查看,必须要启动一个服务才可以查看,继续执行下面的命令

 allure serve report/allure_raw 

可以看到在本地启动了一个服务

查看报告

想要关闭服务,执行ctrl+c,Allure的使用方法还有很对,我们后面再继续介绍。

关注个人公众号:测试开发进阶之路

  

原文地址:https://www.cnblogs.com/zengxuejie/p/13786522.html