首页 文章

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

提问于
浏览
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);

}

1 回答

  • 1

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

    这是正常的 get

相关问题