2

我正在尝试使用 categories.json 文件按不同类别的失败测试结果进行分类。我正在使用以下 JSON 文件:

[
    {
      "name": "Ignored tests", 
      "matchedStatuses": ["skipped"]
    },
    {
      "name": "Infrastructure problems",
      "matchedStatuses": ["broken", "failed"],
      "messageRegex": ".*An unknown server-side error occurred.*"
    },
    {
      "name": "Outdated tests",
      "matchedStatuses": ["broken"],
      "traceRegex": ".*FileNotFoundException.*"
    },
    {
      "name": "Test defects",
      "matchedStatuses":[
          "broken",
          "Element is not currently visible and may not be manipulated"
        ],
      "traceRegex":[
          ".*Cannot read property.*",
          ".*is not in DOM or there is no element.*",
          ".*is not a function.*"
        ]
    },
    {
      "name": "Element Not visible",
      "traceRegex":[
          ".*still not visible after.*",
          ".*Element is not currently visible and may not be manipulated.*",
          ".*was not found by text|CSS|XPath.*"
        ]
    },
    {
      "name":"Promise Rejected",
      "traceRegex": [".*Promise was rejected with the following reason.*"]
    }
  ]

并在魅力报告中只获得产品缺陷。

这是它的样子

我正在使用诱惑:2.8.1 codeceptjs:1.4.6 appium:1.8.2

4

2 回答 2

0

您的categories.json文件格式错误(traceRegex应该是字符串)。如果您希望每个类别有多个匹配器,只需使用相同的名称:

[{
  "name": "Element Not visible",
  "traceRegex": ".*still not visible after.*"
}, {
  "name": "Element Not visible",
  "traceRegex": ".*Element is not currently visible and may not be manipulated.*"
}]
于 2019-02-14T14:36:22.173 回答
0

除了Dmitry Baev 的回答之外,您还可以随时使用“|” -正则表达式交替运算符(| 或 |)

在您的情况下,它将如下所示:

{
  "name": "Element Not visible",
  "traceRegex": "(.*still not visible after.*)|(.*Element is not currently visible and may not be manipulated.*)|(.*was not found by text|CSS|XPath.*)"
}

可以进一步简化为:

{
  "name": "Element Not visible",
  "traceRegex": ".*(still not visible after)|(Element is not currently visible and may not be manipulated)|(was not found by text|CSS|XPath).*"
}
于 2021-03-30T01:53:29.690 回答