0

我正在尝试 在 Python 教程中使用 Behave 进行测试。我可以让导入工作,但“执行详细信息显示 Cucumber 场景的结果”。不起作用。 

这就是我正在做的事情:

  • 我正在创建一个新的测试执行(比如 PROJ-123)。
  • 我正在创建一个新的自动化 [Cucumber] 测试(例如,PROJ-234)
  • 我正在创建一个新的自动化 [Cucumber] 测试(例如,PROJ-345)

我将以下功能文件与 Behave 一起使用

@PROJ-123
Feature: Verify something

Scenario Outline: Verify something with <data>
  Given I use the data <data>
   Then the result is <result>

@PROJ-234
Examples:
| data | result |
|  1   |    1   |

@PROJ-345
Examples:
| data | result |
|  2   |    4   |

我正在运行:

behave -k --format=cucumber_json:PrettyCucumberJSONFormatter -o cucumber.json --junit --format=json -o reports/data.json x.feature

我正在导入报告:

curl -H "Content-Type: application/json" -X POST -u user:password --data @reports/data.json "https://jira.example.com/rest/raven/1.0/import/execution/behave"

服务器回复是:

{"testExecIssue":{"id":"574356","key":"PROJ-123","self":"https://jira.example.com/rest/api/2/issue/574356"},"testIssues":{"success":[{"id":"574408","key":"PROJ-234","self":"https://jira.example.com/rest/api/2/issue/574408"},{"id":"574409","key":"PROJ-345","self":"https://jira.example.com/rest/api/2/issue/574409"}]}}

但是当我查看 PROG-234 或 PROJ-345 的测试详细信息时,它是空的: 它是空的

我还尝试导入 Cucumber JSON 测试报告:

curl -H "Content-Type: application/json" -X POST -u user:pass --data @cucumber.json https://jira.example.com/rest/raven/1.0/import/execution/cucumber

{"testExecIssue":{"id":"574356","key":"PROJ-123","self":"https://jira.example.com/rest/api/2/issue/574356"},"testIssues":{"success":[{"id":"574408","key":"PROJ-234","self":"https://jira.example.com/rest/api/2/issue/574408"},{"id":"574409","key":"PROJ-345","self":"https://jira.example.com/rest/api/2/issue/574409"}]}}

结果完全相同:PROG-234 或 PROJ-345 的测试详细信息为空。

我正在使用带有 Xray 的 Jira Data Center v8.13.1。

编辑1:塞尔吉奥在下面的评论指出,如果我有像下面这样的功能,它应该可以工作:

@PROJ-123
Feature: Verify something

  @PROJ-234
  # Jira Test ID
  Scenario Outline: Verify something with <data>
    Given I use the data <data>
     Then the result is <result>

Examples:
  | data | result |
  |   1  |    1   |
  |   2  |    4   |

第二个功能文件生成以下 Cucumber JSON 报告:

[
{
  "description": "",
  "elements": [
    {
      "description": "",
      "id": "verify-something;verify-something-with-1----@1.1-",
      "keyword": "Scenario Outline",
      "line": 13,
      "location": "x.feature:13",
      "name": "Verify something with 1 -- @1.1 ",
      "steps": [
        {
          "keyword": "Given",
          "line": 7,
          "match": {
            "location": "steps/x.py:3"
          },
          "name": "I use the data 1",
          "result": {
            "duration": 1996756,
            "status": "passed"
          },
          "step_type": "given"
        },
        {
          "keyword": "Then",
          "line": 8,
          "match": {
            "location": "steps/x.py:7"
          },
          "name": "the result is 1",
          "result": {
            "duration": 993013,
            "status": "passed"
          },
          "step_type": "then"
        }
      ],
      "tags": [
        {
          "line": 1,
          "name": "PROJ-234"
        }
      ],
      "type": "scenario"
    },
    {
      "description": "",
      "id": "verify-something;verify-something-with-2----@1.2-",
      "keyword": "Scenario Outline",
      "line": 14,
      "location": "x.feature:14",
      "name": "Verify something with 2 -- @1.2 ",
      "steps": [
        {
          "keyword": "Given",
          "line": 7,
          "match": {
            "location": "steps/x.py:3"
          },
          "name": "I use the data 2",
          "result": {
            "duration": 1998901,
            "status": "passed"
          },
          "step_type": "given"
        },
        {
          "keyword": "Then",
          "line": 8,
          "match": {
            "location": "steps/x.py:7"
          },
          "name": "the result is 4",
          "result": {
            "duration": 0,
            "status": "passed"
          },
          "step_type": "then"
        }
      ],
      "tags": [
        {
          "line": 1,
          "name": "PROJ-234"
        }
      ],
      "type": "scenario"
    }
  ],
  "id": "verify-something",
  "keyword": "Feature",
  "line": 2,
  "name": "Verify something",
  "status": "passed",
  "tags": [
    {
      "line": 1,
      "name": "PROJ-123"
    }
  ],
  "uri": "x.feature"
}
]

它没有。测试详细信息仍为空(带有行为或 Cucumber 报告)。

4

2 回答 2

0

目前不支持给定场景大纲中的多个“示例”部分。此外,标签应该添加到场景大纲条目中,而不是示例部分。另一个重要的事情是您拥有的测试,黄瓜类型应该是“场景大纲”而不是“场景”。这应该可以解决您最初的问题。

于 2021-03-19T10:12:07.657 回答
0

这不应该工作,我应该更仔细地阅读教程:

测试(规范)最初在 Jira 中创建为 Cucumber 测试,然后使用 UI 或 REST API 导出。

测试详细信息不会由测试报告填充。

于 2021-03-19T17:54:44.037 回答