Pytest框架+Allure报告

Pytest框架+Allure报告

简介:
Allure Framework是一种灵活的轻量级多语言测试报告工具,不仅可以以简洁的网络报告形式非常简洁地显示已测试的内容,而且还允许参与开发过程的每个人从日常执行中提取最大程度的有用信息。

安装库:
pip install pytest
pip install allure-pytest
pip install pytest-allure-adaptor

allure是一个命令行工具,需要去github上下载最新版 :https://github.com/allure-framework/allure2/releases
在这里插入图片描述

下载完成之后,解压到本地电脑;把bin目录添加到环境变量Path下。在这里插入图片描述
示例:

import allure
import pytest
import os

@allure.step("操作步骤1的描述")
def setp1():
    print('操作步骤1')
@allure.step("操作步骤2的描述")
def setp2():
    print('操作步骤2')

@allure.feature('测试接口--模块描述')
class Test_01(object):
    @allure.story('测试用例的描述--测试用例1')
    def test_01(self, first):
        '''
        用例详情描述
        :param first: 前置条件
        :return:
        '''
        setp1()
        setp2()
        print('test_01,调用first成功', first)
        assert 1 == 1
    @allure.story('测试用例的描述--测试用例2')
    def test_02(self):
        print('test_02,不需要调用')
    @allure.story('测试用例的描述--测试用例3')
    def test_03(self, first2):
        print('test_03,调用first成功', first2)

#生成测试报告数据
pytest.main(['allureTest.py','--alluredir','./report/allure_raw'])
#测试报告在线预览-浏览器访问(使用火狐/谷歌--设置默认浏览器)
os.system('allure serve ./report/allure_raw')
#生成本地测试报告静态数据页面(可手动对index.html用浏览器打开查看)
os.system('allure generate ./report/allure_raw/ -o ./report/html/ --clean')

生成测试报告:
在这里插入图片描述

Allure相关的内容在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值