如何使用空手道测试下载api

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

我有一个api文件下载(txt,.doc,*。csv)使用java.i中的spring框架想要使用空手道进行验收测试。我可以这样做。

这是我的代码

@RequestMapping(path = "/download", method = RequestMethod.GET)
public ResponseEntity<Resource> download(String param) throws 
IOException {
InputStreamResource resource = new InputStreamResource(new FileInputStream(file));
return ResponseEntity.ok()
        .headers(headers)
        .contentLength(file.length())
        .contentType(MediaType.parseMediaType("application/octet-stream"))
        .body(resource);

}

karate
1个回答
1
投票

请参阅此示例upload.feature中的第16行

这是一个正常的get

© www.soinside.com 2019 - 2024. All rights reserved.