• pytest(二十七)--allure-pytest


    allure-pytest环境准备

    windows环境相关:

    python 3.7版本

    pytest  5.4.3版本

    allure-pytest 2.8.17 最新版

    使用pip install allure-pytest安装

     allure命令行工具

    allure是一个命令行工具,需要去github上下载最新版https://github.com/allure-framework/allure2/releases

    下载完成之后,解压到本地电脑

    把bin目录添加到环境变量Path下

    用例demo

    conftest.py内容

    #conftest.py
    import pytest
    
    @pytest.fixture(scope="session")
    def login():
        print("用例先登录") 

    test_answers.py内容

    #test_answers.py
    # encoding:utf-8
    import allure
    import pytest
    @allure.step("步骤1,点xx")
    def steps_1():
        print("11")
    @allure.step("步骤2,点xx")
    def steps_2():
        print("22")
    
    @allure.feature("编辑页面")
    class TestEditPage():
        '''编辑页面'''
        @allure.story("这是一个xxx的用例")
        def test_1(self,login):
            '''用例描述:先登录再去执行xxx'''
            steps_1()
            steps_2()
            print("xxx")
    
        @allure.story("打开a页面")
        def test_2(self,login):
            '''用例描述:先登录再去执行yyy'''
            print("yyy")  

    执行用例

    cd 到test_answers.py所在的目录文件,命令行执行

    pytest --alluredir ./report/allure_raw

    执行完成后,在当前目录下,report目录会生成一个allure_raw的原始文件,这个只是测试报告的原始文件,不能打开成html报告

     打开html的报告需要启动allure服务,启动命令如下

    allure serve report/allure_raw

    启动服务,它会自动给个端口,直接用默认浏览器打开了

     查看报告

    默认使用IE打开,一直在转圈,复数链接,放到谷歌浏览器上,秒开

     

     点EN 按钮可以查看中文报告

     打开测试套,可以查看报告的详情,显示的还是很详细的

    越努力,越幸运!!! good good study,day day up!!!
  • 相关阅读:
    位操作符:&位与、|位或、^异或、~求反、<<左移位、>>带符号右移位、>>>无符号右移位
    【leetcode】496. Next Greater Element I
    after_create and after_commit
    rails跳过回调的方法
    ruby执行周期性任务
    Nokogiri爬虫教程
    用ruby调用执行shell命令
    Redis使用详细教程
    rails中params[:id]与params["id"]分析
    mysql备份与恢复数据
  • 原文地址:https://www.cnblogs.com/canglongdao/p/13410178.html
Copyright © 2020-2023  润新知