空手道api测试中不存在iRequired请求部分“文件" [英] iRequired request part 'files' is not present in karate api testing
本文介绍了空手道api测试中不存在iRequired请求部分“文件"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试使用以下功能时,我正在获取所需的请求部分文件"不存在功能:验证API是否正确返回了产品
when i try to use this below feature i am getting Required request part 'files' is not present Feature: Verify that products are properly returned by the 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测试提出正确的解决方案或替代方法
please suggest proper solution or alternative for file upload api test
推荐答案
请参阅 multipart文件
文档: 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' }
这篇关于空手道api测试中不存在iRequired请求部分“文件"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文