[英]How to read input data from an excel spreadsheet and pass it JSON payload in karate framework?
I need to create data driven unit tests for different APIs in karate framework.我需要为空手道框架中的不同 API 创建数据驱动的单元测试。 The various elements to be passed in the JSON payload should be taken as input from an excel file.在 JSON 有效载荷中传递的各种元素应作为 excel 文件的输入。
A few points:几点:
call-table.feature
and dynamic-params.feature
请参考以下示例: call-table.feature
和dynamic-params.feature
call-json-array.feature
接下来我建议使用 JSON 而不是 Excel 或 CSV 文件,空手道本身就支持它: call-json-array.feature
Map
/ List
form, it will be ready for Karate to use.最后,如果您真的愿意,您可以调用任何 Java 代码,并且如果您以Map
/ List
形式返回数据,它将可供空手道使用。 This example shows how to read a database via JDBC: dogs.feature
.这个例子展示了如何通过 JDBC 读取数据库: dogs.feature
。 So although this is not built into Karate, just write a simple utility to read a CSV or Excel file and you can do pretty much anything Java can do.因此,尽管这不是空手道内置的,但只需编写一个简单的实用程序来读取 CSV 或 Excel 文件,您就可以完成 Java 可以做的任何事情。EDIT: Karate now supports CSV files that can be used to even do data-driven testing: https://github.com/intuit/karate#csv-files编辑:空手道现在支持 CSV 文件,甚至可以用来进行数据驱动测试: https ://github.com/intuit/karate#csv-files
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.