Pytest生成allure报告

  • 依赖安装:  

    # 安装allure-pytest
    pip3 install allure-pytest --index-url https://pypi.douban.com/simple      # 请先卸载掉 pytest-allure-adaptor
    # 安装allure启动一个服务来读取报告
    https://github.com/allure-framework/allure2/releases  # 我这里安装的2.14 直接下载deb包然后安装
    # 执行用例生成后会生成原始文件.json这个只是测试报告的原始文件,不能打开成html的报告
    pytest --alluredir reults/
    # 执行完成后pytest --alluredir report/,report目录会生成一个allure_raw的原始文件,这个只是测试报告的原始文件,不能打开成html的报告
    # 这个时候需要启动allure服务器来读取对应的原始文件,
    sudo allure serve reults/
  • 运行测试:

    • test_desktop.py
      
      import pytest
      
      
      @pytest.mark.Desktop_Professional
      @pytest.mark.特性1
      def test_1():
          print('执行了桌面专业版特性1用例')
          assert True
      
      
      @pytest.mark.Desktop_Professional
      @pytest.mark.特性2
      def test_2():
          print('执行了桌面专业版特性2用例')
          assert False
      
    • 终端运行:
      pytest -v  test_desktop.py   --alluredir reults
      

      项目目录下面生成一个reults文件

    • 查看报告命令:
      sudo allure serve reults/ 
  • 报告样式:

相关文章

目录1、前言2、mark的使用(一)注册自定义标记(二)在测试...
用例执行状态用例执行完成后,每条用例都有自己的状态,常见...
什么是conftest.py可以理解成一个专门存放fixture的配置文件...
前言pytest默认执行用例是根据项目下的文件名称按ascii码去收...
前言:什么是元数据?元数据是关于数据的描述,存储着关于数...