问题描述
我正在尝试按照 Testing using Behave in Python 教程进行操作。我可以使导入工作,但“执行详细信息显示 Cucumber 方案的结果”。不起作用。
这是我正在做的事情:
- 我正在创建一个新的测试执行(比如 PROJ-123)。
- 我正在创建一个新的自动化[Cucumber] 测试(比如 PROJ-234)
- 我正在创建一个新的自动化[Cucumber] 测试(比如 PROJ-345)
@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","self":"https://jira.example.com/rest/api/2/issue/574409"}]}}
结果完全相同:PROG-234 或 PROJ-345 的测试详细信息为空。
我将 Jira 数据中心 v8.13.1 与 Xray 结合使用。
编辑 1:下面 Sergio 的评论指出,如果我有一个像下面这样的功能,它应该可以工作:
@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 |
[
{
"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,"step_type": "then"
}
],"tags": [
{
"line": 1,"name": "PROJ-234"
}
],"type": "scenario"
},{
"description": "","id": "verify-something;verify-something-with-2----@1.2-","line": 14,"location": "x.feature:14","name": "Verify something with 2 -- @1.2 ","name": "I use the data 2","result": {
"duration": 1998901,"name": "the result is 4","result": {
"duration": 0,"type": "scenario"
}
],"id": "verify-something","keyword": "Feature","line": 2,"name": "Verify something","status": "passed","tags": [
{
"line": 1,"name": "PROJ-123"
}
],"uri": "x.feature"
}
]
它没有。测试详细信息仍然是空的(带有行为或黄瓜报告)。
解决方法
目前不支持给定场景大纲中的多个“示例”部分。 此外,标签应该添加到场景大纲条目而不是示例部分。 另一个重要的事情是您拥有的测试,黄瓜类型应该是“场景大纲”而不是“场景”。这应该可以解决您最初的问题。
,这不应该工作,我应该更仔细地阅读教程:
测试(规范)最初在 Jira 中创建为 Cucumber 测试,然后使用 UI 或 REST API 导出。
测试详细信息不会由测试报告填充。