zoukankan      html  css  js  c++  java
  • 7.pytest测试完成后通过allure生成测试报告

    本篇文章写的是通过allure生成测试报告,当然pytest有自己生成测试报告方式,官网网站也提供了报告优化的代码。但是相比起来还是allure的报告更能直观的显示;

    1.allure环境搭建

    安装python支持的allure第三方模块

    pip install allure-pytest

    安装allure命令行工具,后期用来启动服务

    # github 中下载
    https://github.com/allure-framework/allure2/releases

    将下载的allure中的bin目录配置到环境变量

     2.编写用例,通过allure装饰器形式标记用例(详细的标记在下方)

    import allure
    
    @allure.feature('计算器模块')
    class Test_login():
    
        @allure.story('第一个测试用例')
        def test_1(self):
            assert 1+2 == 3
    
        @allure.story('第二个测试用例')
        def test_2(self):
            assert 2-2 == 0
    
        @allure.story('第三个测试用例')
        def test_3(self):
            assert 3*3 == 9
    
        @allure.story('第四个测试用例')
        def test_4(self):
            assert 10/2 ==5

    3.执行用例

    # 指定报告存放路径
    pytest test_5.py --alluredir ./report

    测试结束后报告并非html格式

     启动allure服务,展示测试报告

    allure serve report # report为上一步指定的报告路径,系统会自动分配端口

     4.allure详细标记用例格式

    临时挂上官网描述,后期补充  https://docs.qameta.io/allure/#_pytest

     

  • 相关阅读:
    无题
    赌对了
    赌:
    这次是真的再见了,oi退役回忆录
    线段树(lazy标记)
    《挑战》2.1 POJ POJ 1979 Red and Black (简单的DFS)
    《挑战》2.1 POJ 2386 Lake Counting (简单的dfs)
    TC安装全系列教程
    ProblemC 剪花布条(KMP基础)
    多校+CF简单题
  • 原文地址:https://www.cnblogs.com/XhyTechnologyShare/p/12268119.html
Copyright © 2011-2022 走看看