我正在尝试 在 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 报告)。