【问题标题】:Importing cucumber json result from karate feature file to Xray将空手道特征文件中的黄瓜 json 结果导入 Xray
【发布时间】:2022-01-03 15:07:44
【问题描述】:

我正在尝试为导入执行结果调用“POST /rest/raven/1.0/import/execution/cucumber/multipart” - REST

由于这个端点允许你发送两个 JSON 文件,我写了下面的空手道测试

@UploadResultMultiPartURL 场景:将执行结果导出到 xray 测试计划 给定路径“导入/执行/黄瓜/多部分” 并且标头 Authorization = 'Bearer' + accessToken 而多部分文件信息 = { read('classpath:data/testplanwithkey.json'), filename: 'testplanwithkey.json', contentType: 'application/json' } 多部分文件结果 = { read('classpath:JiraReports/cucumber.json'), filename: 'cucumber.json', contentType: 'application/json' } 当方法发布时 并打印响应

我怎么会空手道响应
15:50:50.334 [打印] { “错误”:“意外字段(结果)” }

我已附上我的空手道成绩文件以供参考。请告诉我哪里出错了。

我也尝试过使用rest api,我将上传结果,但不确定空手道哪里出了问题: ResponseBody responseBody = given() .multiPart("results", new File(CUCUMBER_RESULT_FILE)) .mul .multiPart("info", "info.json", jiraExecutionJson.getBytes()) .header("Authorization", "Bearer " + jiraTokenGenerator.getXrayToken()) .post(JIRA_IMPORT_EXECUTION_MULTIPART_URL) .getBody();

【问题讨论】:

标签: karate jira-xray


【解决方案1】:

问题似乎出在你的空手道规范中,你有一个名为“result”的多部分,它应该被命名为“results”。

And multipart file results = ....

仅供参考,您可以在此处查看python code 实现类似请求。

【讨论】:

  • 谢谢你的回答,可能我现在向前迈了一步,但在运行空手道测试时仍然出现错误:{"error":"Error parsing results file!"} 11:47 :40.571 [main] INFO com.intuit.karate - [print] { "error": "错误解析结果文件!"我也尝试通过邮递员工具手动执行相同的文件和相同的步骤,并且能够执行测试,但遇到空手道测试问题
  • @abdulkhan 您遇到了哪个错误?
  • {"error":"解析结果文件出错!"} 11:47:40.571 [main] INFO com.intuit.karate - [print] {"error":"解析结果文件出错! " }
【解决方案2】:

我终于设法通过使用 value: alternative to read 解决了这个问题,在极少数情况下正在上传 JSON 或 XML 文件之类的内容并且您希望动态创建它。所以早些时候我试图用 And multipart file info = { read('classpath:data/testplanwithkey.json'), filename: 'testplanwithkey.json' } 这对我有用

 And def value = read('classpath:data/testplanwithkey.json')
And multipart file info = { value: '#(value)', filename: 'testplanwithkey.json' }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-24
    • 1970-01-01
    • 1970-01-01
    • 2016-12-23
    • 1970-01-01
    • 2016-06-04
    相关资源
    最近更新 更多