空手道api测试中不存在所需的请求部分'文件'

问题描述 投票:1回答:1

当我尝试使用以下功能时,我将获得所需的请求部分'文件'不存在功能:验证API正确返回的产品

Background:
* url 'http://localhost:8080'

Scenario: Products are returned on post

Given path 'upload'
And multipart field files = read('test.txt')    
When method post
Then status 200
And match $ == {error: false, bytesUploaded:'#notnull'}

请为文件上传api测试建议正确的解决方案或替代方案

karate
1个回答
0
投票

请参阅multipart file文档:https://github.com/intuit/karate#multipart-file

Given path 'upload'
And multipart file files = { read: 'test.txt', filename: 'test.txt', contentType: 'text/plain' }
When method post
Then status 200
And match $ == { error: false, bytesUploaded: '#notnull' }
© www.soinside.com 2019 - 2024. All rights reserved.