pytest01--生成测试报告及allure的介绍

pytest如何生成测试报告呢?

1、pytest -html=report/report.html --self-contained-html

      report/report.html——指定路径

     ----self-contained-html——报告独立显示,保存样式(把css样式合并到html里)

2、生成allure报告

   2-01:pytest case -alluredir=allure-report --clean-alluredir --reruns 2 -m huohuo

    case——运行根目录下case包中所有符合条件的用例

    -alluredir=allure-report——指定allure报告存放的位置

    --clean-alluredir——每次删除allure报告数据路径

   --reruns 2——失败的用例重跑两次,需结合pytest-rerunfailures库

   -m huohuo——只运行标记huohuo的用例

   2-02:pytest --alluredir ./report/allure_raw

   ./report/allure_raw:指定测试报告存放路径,存放的是json格式的数据

 

 如何运行生成的allure报告呢?———— allure serve report/allure_raw

allure介绍

1、所对应的的等级

      blocker :阻塞功能(功能未实现,无法下一步)

      critical :严重缺陷(功能点缺失)

      normal :一般缺陷(边界情况,格式错误)

      minor :次要缺陷(界面错误与ui需求不符)

      trivial :轻微缺陷(必填项无提示,或者提示不规范)

使用@allure.severity装饰器按严重等级标记case

eg:@allure.severity("blocker"),没被标记severity的用例会默认为normal哦。

如果运行级别为blocker和critical的用例,则可以使用:pytest --alluredir ./allure --allure-severities=blocker,critical

2、--来自上海悠悠的博客

 

原文地址:https://www.cnblogs.com/KeenaCherry/p/12845506.html