Allure简介

  • Allure是一款轻量级并且非常灵活的开源测试报告框架。
  • 它支持绝大多数测试框架, 例如TestNG、Pytest、JUint等。
  • 它简单易用,易于集成。
  • 官网:
  • 文档:

windows下Allure安装方法

allure与pytest集成

  • 安装allure-pytest插件:
    pip install allure-pytest
  • 运行测试用例,allure生成json格式测试报告:
    pytest --alluredir=./report/result
  • 生成html格式allure测试报告:
    allure generate ./report/result -o ./report/allure_html_report --clean
  • 查看报告:
    运行之后,就会生成一个文件夹,打开index.html

allure常用特性

  • allure常用特性:测试报告中展示
    @allure.feature (用于描述被测试产品需求)
    @allure.story (用于描述feature的用户场景,即测试需求)
    with allure.step() (用于描述测试步骤,将会输出到报告中
    allure.attach (用于向测试报告中输入一些附加的信息,通常是一些测试数据,截图等)

pytest.ini文件配置allure

  • pytest.ini文件中加入命令生成json格式的临时报告
    addopts = --reruns 2 --reruns-delay 3 --html=./report/report.html --alluredir ./report/result

运行生成报告

  • D:\PycharmProjects\aiseProject2>pytest
    ……PASSED [100%]
    ----- generated html file: file://D:\PycharmProjects\aiseProject2\report\report.html ----------
    =========== 10 passed in 649.80s (0:10:49) ==============
  • D:\PycharmProjects\aiseProject2>allure generate ./report/result -o ./report/allure_html_report --clean
    Report successfully generated to .\report\allure_html_report
查看Allure报告
  • 用浏览器打开report/result/index.html
  • Selenium65-Allure报告_html_03




作者:暄总-tester