空手道能够验证Excel文件的下载端点吗? [英] Is Karate able to validate Excel file for a download endpoint?

查看:38
本文介绍了空手道能够验证Excel文件的下载端点吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试确认从api下载的文件.在查看了如何使用空手道测试下载api 的建议后,我场景的写法如下:

I am trying to confirm the file downloaded from an api. After reviewing the recommendation from How to test download api using karate, my scenario was written like below:

Scenario: GET /project - Export project listing 
Given params { someparam: 'paramvalue' }
When method GET
Then status 200
And match header Content-Disposition == 'attachment;filename="someFile.xlsx"'
And match header Content-Type == 'application/vnd.ms-excel'
And match response == read('data/exported.xlsx')

前2场比赛通过.但是,最后一次匹配(比较实际文件)失败,并且两个文件都以二进制形式输出,并且显示原因:不相等".

The first 2 matches pass. However, the last match (comparing the actual file) fails with a binary printout of both files and "reason: not equal".

比较中的文件"exported.xlsx"是通过邮递员完成的完全相同的请求的输出,因此它们应该匹配.

The file "exported.xlsx" in the comparison was the output of the exact same request done via Postman, so they should match.

read()是否能够处理excel和csv文件?任何帮助,将不胜感激.

Is read() able to handle excel and csv files? Any help would be appreciated.

推荐答案

据我所知,这应该可行. read('data/exported.xlsx')将返回字节流.

As far as I know this should have worked. read('data/exported.xlsx') will return a stream of bytes.

如果这确实是一个错误,那么请遵循以下过程为社区提供出色的服务: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

If this is indeed a bug you will do a great service to the community if you follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

这篇关于空手道能够验证Excel文件的下载端点吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆