zoukankan      html  css  js  c++  java
  • Allure测试框架 python

    关于Allure

    Allure是一个report框架,可以基于一些测试框架生成测试报告,比较常用的一般是Junit/Testng框架;

    Allure 生成的报告样式简洁美观,同时又支持中文;

    Allure还支持使用Jenkins工具持续集成,整套环境搭建下来以后,使用起来非常方便。

    分析测试的整体趋势

    实现自动化测试用例与手动测试用例关联

    下载allure

    https://dl.bintray.com/qameta/generic/io/qameta/allure/allure/2.7.0/allure-2.7.0.zip

    并配置环境变量

    详情参考:https://www.jianshu.com/p/5735d388faa2

    官网:

    http://allure.qatools.ru/

    下载:pip install allure-pytest

    使用

    pytest --alluredir=/tmp/my_allure_results

    pytest test_baidu.py --alluredir ./result1

    生成报告:allure serve /tmp/my_allure_results

    Allure特性

    pytest test_baidu.py --alluredir ./result1 --allure-features "搜索类"

    import allure
    
    @allure.feature("搜索类")
    class TestSearchDemo:
        @allure.story("搜索 英文")
        def test_search(self):
            print("这是一个搜索测试 英文")
    
        @allure.story("搜索 中文")
        def test_search1(self):
            print("这是一个搜索测试1 中文")
    
        @allure.story("搜索 特殊字符")
        def test_search2(self):
            print("这是一个搜索测试2 特殊字符")

     清除之前的记录: --clean-alluredir

    添加图片,html代码块,视频

    import allure
    import pytest
    
    
    @allure.feature("搜索类")
    class TestSearchDemo:
        @allure.story("搜索 英文")
        #关键字驱动
        @pytest.mark.parametrize("searchkey",[
            "android","连衣裙","$#2!"
        ])
        def test_search(self,searchkey):
            with allure.step("第1步"):
                print("第一步:打开搜索页面")
            with allure.step("第2步"):
                print("第二步:点击搜索框")
            with allure.step("第3步"):
                print(f"第三步:输入搜索词:{searchkey}")
    
    
        @allure.story("搜索 中文")
        def test_search1(self):
            print("这是一个搜索测试1 中文")
    
        @allure.story("搜索 特殊字符")
        def test_search2(self):
            print("这是一个搜索测试2 特殊字符")
    
    @allure.feature("登录类")
    class TestLoginDemo:
        def test_login1(self):
            #插入图片
            allure.attach('<img class="s_lg_img_gold_show" src="//www.baidu.com/img/flexible/logo/pc/result.png" alt="到百度首页" title="到百度首页">',
                          attachment_type=allure.attachment_type.HTML)
            #插入本地图片
            allure.attach.file('/Users/ADMIN/Desktop/a8d5a467242709a8c3a49a336abae8cd_1.PNG',
                attachment_type=allure.attachment_type.PNG)
            # 插入本地视频  allure.attach.file   allure.attachment_type.MP4
            print("login1")
    
        def test_login2(self):
            print("login2")
    
        def test_login3(self):
            print("login3")

     

     

  • 相关阅读:
    PostgreSQL缺省值
    PostgreSQL表的基本概念
    PostgreSQL调用函数
    4.2. PostgreSQL值表达式
    3.5. PostgreSQL继承
    3.4. PostgreSQL事务
    3.3. PostgreSQL外键
    3.2. PostgreSQL视图
    碰撞
    骨骼
  • 原文地址:https://www.cnblogs.com/wangxue1314/p/13472496.html
Copyright © 2011-2022 走看看