zoukankan      html  css  js  c++  java
  • Pytest+Allure定制报告

    Feature: 标注主要功能模块
    Story: 标注Features功能模块下的分支功能
    Severity: 标注测试用例的重要级别
    Step: 标注测试用例的重要步骤
    Issue和TestCase: 标注Issue、Case,可加入URL

    1、Features定制详解
    import allure
    import pytest
    
    
    @allure.feature('test_module_01')
    def test_case_01():
        """
        用例描述:Test case 01
        """
        assert 0

    2、Story定制详解
    import allure
    import pytest
    
    @allure.feature('test_module_01')
    @allure.story('test_story_01')
    def test_case_01():
        """
        用例描述:Test case 01
        """
        assert 0

    3、用例标题和用例描述定制详解
    import allure
    import pytest
    def test_login(): """ 用户登录用例 """ assert 0

    4 、Severity定制详解

    Allure中对严重级别的定义:

    • Blocker级别:中断缺陷(客户端程序无响应,无法执行下一步操作)
    • Critical级别:临界缺陷( 功能点缺失)
    • Normal级别:普通缺陷(数值计算错误)
    • Minor级别:次要缺陷(界面错误与UI需求不符)
    • Trivial级别:轻微缺陷(必输项无提示,或者提示不规范)
    import allure
    import pytest
    
    @allure.severity('blocker')
    def test_login(): """ 用户登录用例 """ assert 0

     

    5、Step定制详解
    import allure
    import pytest
    
    @allure.step('1.输入用户名2.输入密码3.登录')
    def test_login():
        """
        用户登录用例
        """
        assert 0

    6、Issue和TestCase定制详解
    import allure
    import pytest
    
    @allure.issue("http://www.baidu.com")
    @allure.testcase("http://www.testlink.com")
    def test_login():
        """
        用户登录用例
        """
        assert 0

    8、attach定制详解

    报告可以显示许多不同类型的提供的附件,可以补充测试,步骤或夹具结果。可以通过调用以下内容创建附件allure.attach(body, name, attachment_type, extension)

    1. body - 要写入文件的原始内容。

    2. name - 包含文件名的字符串

    3. attachment_type- 其中一个allure.attachment_type

    4. extension - 提供的将用作创建文件的扩展名。

    或者allure.attach.file(source, name, attachment_type, extension)

    1. source - 包含文件路径的字符串。

      (其他参数相同)

    import allure
    import pytest


    @pytest.fixture
    def attach_file_in_module_scope_fixture_with_finalizer(request):
    allure.attach('A text attacment in module scope fixture', 'blah blah blah', allure.attachment_type.TEXT)

    def finalizer_module_scope_fixture():
    allure.attach('A text attacment in module scope finalizer', 'blah blah blah blah',
    allure.attachment_type.TEXT)
    request.addfinalizer(finalizer_module_scope_fixture)


    def test_with_attacments_in_fixture_and_finalizer(attach_file_in_module_scope_finalizer):
    pass


    def test_multiple_attachments():
    allure.attach.file('./cat.png', attachment_type=allure.attachment_type.PNG)
    allure.attach('<head></head><body> a page </body>', 'Attach with HTML type', allure.attachment_type.HTML)

  • 相关阅读:
    JAVA中 ReentrantReadWriteLock读写锁详系教程,包会
    传统企业的精益转型之路
    什么时候可以使用极限编程?
    “懒蚂蚁”效应在产品开发过程中的应用
    Vue.config.js配置 最新可用版本
    如何查找一个为NULL的MYSQL字段
    MYSQL 50 基础题 (转载)
    记录一下第一次写 50行 SQL代码
    jwtUtils顾名思意
    对于我们程序员来说,基本面是什么呢?
  • 原文地址:https://www.cnblogs.com/peng-lan/p/11357307.html
Copyright © 2011-2022 走看看