Pytest 框架入门02--Allure测试报告

Allure框架是一种灵活的轻量级多语言测试报告工具,它不仅能够以简洁的web报告形式显示已测试的内容,而且允许参与开发过程的每个人从测试的日常执行中提取最大限度的有用信息。

在展开Allure详述前,先上一份测试报告,报告主要包含总览、类别、测试套件、图表、时间刻度、功能、包等7大部分,支持自定义诸多信息,包括附件添加、缺陷链接、案例链接、测试步骤、Epic、Feature、Story、Title、案例级别等,相当强大。

 

 

环境配置:

注:allure依赖java环境,1.8以上

#安装pytest框架 pip install pytest #pytest基本报告,用于生成pytest-html报告 pip install pytest-html pip install allure-pytest pip install pytest-allure-adaptor(allure2可以不用安装这个插件了)



下载Allure命令行工具:

到github上下载Allure2 ,地址:https://github.com/allure-framework/allure2/releases
下载完成后,解压放到C盘目录,并配置好环境变量
如:C:\allure-2.13.6\bin 添加到Path中
在DOS中输入:

allure --version 可查看对应的版本号。

设置pytest.ini

 pytest.ini的介绍可参考:https://www.cnblogs.com/yoyoketang/p/9550648.html

[pytest]
addopts = -s  --html=./report/html/Test_Report.html --alluredir ./report/result        
python_files = test_*.py
python_classes = Test*
python_functions = test_*
  • -s   打开详细信息
  • --html   是pytest-html生成目录和文件
  • --alluredir  是xml报告文件存放目录

 

pytest  执行后会有在 ./report/result目录下生成一堆xml的报告文件,当不是我们最终想要的美观报告。

在终端中输入:
allure generate report/result  -o ./report/allure_html/ --clean

然后再输入,打开美观报告:
allure open ./report/allure_html/

 

 

posted @ 2020-10-23 15:58  沉默的云  阅读(299)  评论(0编辑  收藏  举报