调用Jira Xray Cucumber导入API后测试用例未关联测试执行
问题:Cucumber测试用例无法关联至Test Execution(API/手动导入均失败)
调用/rest/raven/2.0/import/execution/cucumber/multipart API,传入指定参数和Cucumber执行结果后,Test Execution成功创建,但对应的Cucumber测试用例未关联到该Test Execution;手动导入执行结果也出现相同问题,需明确验证方式和排查遗漏点。
传入的Info参数
{"fields": {"project": {"key": "IXXXX"},"summary": "Test Execution for cucumber Execution","description": "For more info please check [here|https://www.example.com]","issuetype": {"id": "10009"}}}
Cucumber执行结果JSON
[{"uri": "features/Login.feature","elements": [{"name": "Successful login with valid credentials","id": "successful-login-with-valid-credentials","steps": [{"name": "I navigate to the login page","keyword": "Given ","result": {"status": "passed"}},{"name": "I enter valid credentials","keyword": "When ","result": {"status": "passed"}},{"name": "I am redirected to the dashboard","keyword": "Then ","result": {"status": "passed"}}]},{"name": "Unsuccessful login with invalid credentials","id": "unsuccessful-login-with-invalid-credentials","steps": [{"name": "I navigate to the login page","keyword": "Given ","result": {"status": "passed"}},{"name": "I enter invalid credentials","keyword": "When ","result": {"status": "failed","errormessage": "Invalid username or password"}},{"name": "I see an error message","keyword": "Then ","result": {"status": "passed"}}]}]},{"uri": "features/Account.feature","elements": [{"name": "Creating a new account","id": "creating-a-new-account","steps": [{"name": "I navigate to the account creation page","keyword": "Given ","result": {"status": "passed"}},{"name": "I enter all required details","keyword": "When ","result": {"status": "passed"}},{"name": "I successfully create a new account","keyword": "Then ","result": {"status": "passed"}}]}]}]
排查验证步骤
1. 检查测试用例匹配规则
- 确认Jira Xray(Raven)中Cucumber测试用例的匹配策略:默认通过
feature文件路径+场景ID/名称匹配,需确保Jira中已导入的测试用例的场景ID、feature路径与执行结果中的完全一致(包括大小写、特殊字符、路径前缀)。 - 查看Xray导入设置,是否开启“自动创建未匹配的测试用例”;若未开启且Jira中无对应测试用例,导入时不会关联任何用例。
2. 验证API请求格式
- 确认
multipart请求格式:需将info作为form-data字段,Cucumber JSON作为results字段(字段名需符合Xray要求),且JSON无语法错误。 - 检查API响应内容,即使Test Execution创建成功,响应的
warnings字段可能提示未找到匹配测试用例的关键信息。
3. 核对项目与用例归属
- 确认传入的
project.key(IXXXX)与Cucumber测试用例所在Jira项目一致,跨项目无法关联。 - 检查
issuetype.id(10009)是否为当前项目有效的Test Execution类型ID,类型不匹配会导致关联逻辑异常。
4. 手动导入额外验证
- 手动导入时使用的Cucumber文件需与API传入内容完全一致,避免编码或格式转换问题。
- 查看手动导入页面的“匹配到的测试用例数量”,若显示0,直接指向测试用例匹配失败,需返回第一步核查。
5. 查看Xray日志
- 进入Jira管理>系统>日志,搜索Cucumber导入相关条目,查找“未找到匹配测试用例”或关联失败的具体原因。
内容的提问来源于stack exchange,提问作者Hari Venkadesh
相关产品推荐
相关产品推荐

