zoukankan      html  css  js  c++  java
  • 【pytest】allure

    【安装】

    1.因为allure2需要在java的环境下,并且要求必须是jdk1.8级以上,所以要首先保证这一点

    2.安装pytest:pip install pytest

    3.安装allure-pytest:pip install allure-pytest

    4.安装allure:

    下载allure2:https://github.com/allure-framework/allure2/releases,我们下载的是allure-2.8.0版本;下载后解压,放在某个位置(建议放在C:python35Libsite-packages下);配置环境变量:环境变量path中加上解压好的文件夹下的bin目录下的allure.bat文件的路径(这里是:E:pythonLibsite-packagesallure-2.8.0in)

    【使用】

    复制代码
     1 #coding=GBK
     2 
     3 import pytest
     4 import allure
     5 from test_api.run.run import Test_run
     6 from test_api.data.get_cookies_value import get_cookies_value
     7 import warnings
     8 import os
     9 
    10 @allure.feature('test-api')  # feature定义功能
    11 class Test_Run():
    12     def setup_method(self, method):  #每个模块开始之前都会执行
    13         print('start.....')
    14 
    15     @allure.story('登录/获取报文')  # story定义用户场景
    16     def test_1(self):
    17         warnings.simplefilter("ignore", ResourceWarning)
    18         # get_cookies_value()
    19         a=Test_run()
    20         a.run()
    21         #断言
    22         assert True
    23 
    24     def teardown_method(self, method):  ##每个模块结束之后都会执行
    25         print('end.....')
    26 
    27 if __name__ == '__main__':
    28     # 生成配置信息 "-s 代表可以将执行成功的案例日志打印出来 ; -q+文件执行路径 代表只需要执行的文件"
    29     pytest.main(['-s','-q',r'E:python_project
    equest_testpytest_allure	est_api_by_pytest.py','--alluredir','./report/xml'])
    30     #os模块运行allure命令,来生成html格式的报告(根据刚刚生成的配置信息)
    31     os.system("E:/python37/Lib/site-packages/allure-2.8.0/bin/allure.bat "
    32               "generate "
    33               "E:/python_project/request_test/pytest_allure/report/xml "
    34               "-o "
    35               "E:/python_project/request_test/pytest_allure/report/html")
    复制代码

     (pytest的setup和teardown,见https://www.jianshu.com/p/a57b5967f08b)

    Or:命令行执行

     生成的报告如下:

     
  • 相关阅读:
    用leangoo看板工具实施多团队大规模敏捷开发
    单团队的Scrum敏捷开发-leangoo
    放弃在每日站会上按成员逐个发言
    Leangoo思维导图做OKR目标管理
    好用的思维导图软件(程序员必备)
    好用免费的思维导图工具,多人协作共同编辑
    什么是Scrum燃尽图?
    Scrum中文网-团队需要Scrum Master做这六件事
    项目管理工具Leangoo自定义字段的应用
    实施敏捷开发中,选择看板管理工具的几个要点
  • 原文地址:https://www.cnblogs.com/gtea/p/15413559.html
Copyright © 2011-2022 走看看