user2176592
user2176592

Reputation: 159

How does allure get the test status in categories.json

After executing test I am getting the XML files in allure-results directory. From there I am generating the HTML report using the command:

allure generate allure-results --clean -o allure-report

In allure-results I have a categories.json file, which is used to categorize tests in the HTML report based on its result (eg: passed, broken, failed, ...). I believe this categorization is done by allure.

So I want to know on what basis allure does this categorization.

categories.json

{
  "name": "Ignored tests",
  "messageRegex": ".*ignored.*",
  "matchedStatuses": [ "skipped" ],
  "flaky": true
},
{
  "name": "Infrastructure problems",
  "traceRegex": ".*RuntimeException.*",
  "matchedStatuses": [ "broken", "failed" ]
},
{
  "name": "Outdated tests",
  "messageRegex": ".*FileNotFound.*",
  "matchedStatuses": [ "broken" ]
},
{
  "name": "Passed",
  "messageRegex": ".*",
  "matchedStatuses": [ "passed" ]
}

Sample test report image:

enter image description here

Upvotes: 1

Views: 5630

Answers (1)

gdyuldin
gdyuldin

Reputation: 156

categories.json should be a list of mappings.

In your case it should looks like

[
  {
    "name": "Ignored tests",
    "messageRegex": ".*ignored.*",
    "matchedStatuses": ["skipped"],
    "flaky": true
  },
  {
    "name": "Infrastructure problems",
    "traceRegex": ".*RuntimeException.*",
    "matchedStatuses": ["broken", "failed"]
  },
  {
    "name": "Outdated tests",
    "messageRegex": ".*FileNotFound.*",
    "matchedStatuses": ["broken"]
  },
  {
    "name": "Passed",
    "messageRegex": ".*",
    "matchedStatuses": ["passed"]
  }
]

Upvotes: 2

Related Questions