zoukankan      html  css  js  c++  java
  • 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!!!
  • 相关阅读:
    easyui combo自动高度(下拉框空白问题)
    log4net
    asp.net mvc 生成条形码
    Kubernetes 初探
    美国最顶级的投资机构在关注什么
    Ansible--01
    第一章 进入java的世界
    正则表达式
    zabbix接口调用注意事项--Python
    Docker+K8S实践
  • 原文地址:https://www.cnblogs.com/canglongdao/p/13410178.html
Copyright © 2011-2022 走看看