zoukankan      html  css  js  c++  java
  • Allure介绍

    以下内容基于pytest的框架进行展示:

    什么是Allure

    Allure是一个独立的报告插件,生成美观易读的报告,目前支持语言:Java, PHP, Ruby, Python, Scala, C#。

    怎么用

    Allure安装

    安装pytest的插件包pytest-allure-adaptor: pip3 install pytest-allure-adaptor

    Allure帮助文档

    https://docs.qameta.io/allure/#_about

    生成Allure报告

    命令行参数:pytest --alluredir report  # 在执行命令目录生成report文件夹,文件夹下包含xml文件

    示例:

    pytest.ini

    [pytest]
    ;--html=./report.html
    #删除原生html,增加Allure
    addopts = -s --alluredir report
    # 测试路径
    testpaths = ./Test
    # 测试文件名
    python_files = test_*.py
    # 测试类名
    python_classes = Test_*
    # 测试的方法名
    python_functions = test_*

    注意:ini不支持注释,请去除文本中注释部分

    test_all.py

    class Test_allure:
            def setup(self):
                pass
            def teardown(self):
                pass
            def test_al(self):
                assert 0

    操作步骤:
    1.命令行进入pytest.ini所在目录
    2.输入命令:pytest
    执行结果:
    1.pytest.ini所在目录生成report文件夹,文件夹下生成一个xml文件

    xml转html工具安装

    mac版本

    1.:brew install allure
    2.进入report上级目录执行命令:allure generate report/ -o report/html
    3.report目录下会生成index.html文件,即为可视化报告

    windows版本

    1.下载压缩包allure-2.6.0.zip
    地址:https://bintray.com/qameta/generic/allure2
    2.解压
    3.将压缩包内的bin目录配置到path系统环境变量
    4.进入report上级目录执行命令:allure generate report/ -o report/html --clean
    5.report目录下会生成index.html文件,即为可视化报告

    Allure之Pytest

    添加测试步骤

    方法:@allure.step(title="测试步骤001")

    示例:
    test_all.py

    import allure, pytest
    class Test_allure:
    def setup(self):
    pass
    def teardown(self):
    pass
    @allure.step('我是测试步骤001')
    def test_al(self, a):
    assert a != 2

    添加测试描述

    方法:allure.attach('描述', '我是测试步骤001的描述~~~')

    示例:

    test_all.py

    import allure, pytest
    class Test_allure:
      def setup(self):
        pass
      def teardown(self):
        pass
      @allure.step('我是测试步骤001')
      def test_al(self, a):
        allure.attach('描述', '我是测试步骤001的描述~~~')
        assert a != 2

    添加严重级别

    测试用例设置不同的严重级别,可以帮助测试和开发人员更直观的关注重要Case.

    方法:@pytest.allure.severity(Severity)
    参数:
    Severity:严重级别(BLOCKER,CRITICAL,NORMAL,MINOR,TRIVIAL)
    使用方式:
    @pytest.allure.severity(pytest.allure.severity_level.CRITICAL)

    示例:

    test_all.py

    import allure, pytest
    class Test_allure:
        def setup(self):
            pass
        def teardown(self):
            pass
                        
        @pytest.allure.severity(pytest.allure.severity_level.CRITICAL)
        @allure.step('我是测试步骤001')
        def test_al(self, a):
            allure.attach('描述', '我是测试步骤001的描述~~~')
            assert a != 2                
  • 相关阅读:
    第六周Java学习总结
    结对编程练习_四则运算(一)
    实验一Java开发环境的熟悉
    第四周Java学习总结
    第三周Java学习总结
    2019-2020-2 20175230滕星《网络对抗技术》Exp9 Web安全基础
    2019-2020-2 20175230 滕星《网络对抗技术》Exp 8 Web基础
    2019-2020-2 20175230滕星《网络对抗技术》Exp7 网络欺诈防范
    2019-2020-2 网络对抗技术 20175230滕星 Exp6 MSF基础应用
    2019-2020-2 网络对抗技术 20175230滕星 Exp5 信息搜集与漏洞扫描
  • 原文地址:https://www.cnblogs.com/shen-qiang/p/9146869.html
Copyright © 2011-2022 走看看