httprunner 3.x 用allure生成测试报告

前提:已安装 allure/allure-pytest/pytest-html

首先验证allure版本

通过hrun -h可查

 主要两个步骤

1.用 --alluredir运行测试用例

2.生成报告

进入测试用例目录下

1、指定运行用例:pytest 测试文件 --alluredir report 或者 hrun 测试文件 --alluredir report 

测试文件:如果是填写文件名,默认是当前路径的文件,如果要运行指定文件,则测试文件要带上路径

reprort: 是用于存放的文件(默认是存放在当前路径,如果要存放在指定路径,则文件名要带上路径)

pytest运行的测试用例只能是.py格式,hrun运行的测试用例,可以是pytest格式,也可以是yml格式

 步骤一:运行测试用例

pytest hetest_re_test.py --alluredir report
或者

  hrun hetest_re.yml --alluredir=report

 运行结果如下:

  

 会在当前文件夹下生成测试结果文件夹 .pytest_cache、report

 步骤二 :生成报告

allure generate report  # 默认在当前目录下生成allure-report文件

 allure generate report -o allure-report --clean  #  --clean是为了清空已有的测试报告; -o allure-report 是指定清空测试报告的文件allure-report

allure generate report运行结果如下:

allure generate report -o allure-report --clean运行结果如下:

 会在当前文件夹生成 allure-report 文件夹,包含HTML测试报告 index.html ,然后用浏览器打开查看

  

2、全部运行:pytest --alluredir report

全部运行的是test_.*py的文件

pytest --alluredir report

会在当前文件夹下生成测试结果文件夹 .pytest_cache、report

allure generate report

同样会在当前文件夹生成 allure-report 文件夹,包含HTML测试报告 index.html,含所有测试用例结果数据


猜你喜欢

转载自www.cnblogs.com/may18/p/13378292.html