allure工具的安装及使用

allure 一个测试报告生成工具

allure工具的安装及配置

1、python包的安装

pip install allure-pytest

2、allure工具包的安装及配置

# 下载地址(可直接下载zip包进行解压)
https://github.com/allure-framework/allure2/releases

# 添加环境变量
# allure安装目录下的 allure-2.17.3/bin/allure 添加到path中

# 安装后查看版本
allure --version

下载清单

安装并配置环境变量后,查看版本

 allure的使用

编写测试代码

# -*- coding: utf-8
import allure


@allure.step("步骤1:step1")
def step_1():
    print("step1")


@allure.step("步骤2:step2")
def step_2():
    print("step2")


@allure.feature("test")
class TestEditPage():
    @allure.story("test01")
    def test_1(self):
        """这是成功用例"""
        step_1()
        step_2()
        print("测试成功")

    @allure.story("test02")
    def test_2(self):
        """这是失败用例"""
        assert 1 == 2, "测试失败"

    @allure.story("test03")
    def test_3(self):
        """成功用例3"""
        print("test03")

    def test_31(self):
        """成功用例31"""
        print("成功用例31")

    def test_32(self):
        """成功用例32"""
        print("成功用例32")

    @allure.story("test04")
    def test_04(self):
        """成功用例4"""
        print("test04")

    def test_41(self):
        """失败用例41"""
        print("失败用例41")
        assert 1 == 2

    def test_42(self):
        """成功用例42"""
        print("成功用例42")

进入测试demo所在路径下,在终端执行 pytest -s --alluredir report  生成测试报告

# 执行测试用例,并生成测试报告
# alluredir:report 为报告目录 
pytest -s --alluredir report

 执行log

 生成html文件

# 生成 html 命令
allure generate --clean report

# 启用 allure server 展示测试报告
allure serve report

 返回

浏览器自动跳转到 http://172.24.204.104:50218/ 

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值