微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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/ 
  • 报告样式:

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐