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

扫描二维码关注公众号,回复: 16333612 查看本文章

 生成html文件

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

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

 返回

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

 

猜你喜欢

转载自blog.csdn.net/bulucc/article/details/123347505
今日推荐