allure配置ENVIRONMENT和CATEGORIES

背景

如果你想给测试报告配置环境(ENVIRONMENT)和分类(CATEGORIES),需要怎么做呢?非常简单,请按照我们的步骤来

配置ENVIRONMENT

在allre-results目录下(对于我们的项目来说,是allure_reports目录,即生成json和txt的目录),添加environment.properties或environment.xml

environment.properties

systemVersion=Centos7.6
appiumVersion=1.17.0
pythonVersion=3.8.0
allureVersion=2.12.1
phoneSimulator=YeShen
platformName=Android5.1.1, Android7.1.2
appPackage=com.xxzb.fenwoo
appActivity=com.xxzb.fenwoo.activity.addition.WelcomeActivity

或者使用
environment.xml

# 这里是使用官方文档默认的信息,我没有配置
<environment>
    <parameter>
        <key>Browser</key>
        <value>Chrome</value>
    </parameter>
    <parameter>
        <key>Browser.Version</key>
        <value>63.0</value>
    </parameter>
    <parameter>
        <key>Stand</key>
        <value>Production</value>
    </parameter>
</environment>

配置CATEGORIES

默认是有两类缺陷:

  • 产品缺陷(测试结果:failed)
  • 测试缺陷(测试结果:broken)
    同样是在allure-results目录下,添加一个categories.json文件
categories.json
[
  {
    "name": "Ignored tests", 
    "matchedStatuses": ["skipped"] 
  },
  {
    "name": "Infrastructure problems",
    "matchedStatuses": ["broken", "failed"],
    "messageRegex": ".*bye-bye.*" 
  },
  {
    "name": "Outdated tests",
    "matchedStatuses": ["broken"],
    "traceRegex": ".*FileNotFoundException.*" 
  },
  {
    "name": "Product defects",
    "matchedStatuses": ["failed"]
  },
  {
    "name": "Test defects",
    "matchedStatuses": ["broken"]
  }
]

参数含义
name:必填项,分类的名字
matchedStatuses:可选项,测试用例的运行状态,默认是["failed", "broken", "passed", "skipped", "unknown"]
messageRegex:可选项,测试用例运行的错误信息,使用正则表达式匹配。默认是".*"
traceRegex:可选项,测试用例运行的堆栈信息,使用正则表达式匹配。默认是".*"

报告展示

参考文章

《Pytest系列(19)- 我们需要掌握的allure特性》
《allure官方文档》

原文地址:https://www.cnblogs.com/my_captain/p/12768820.html