How to read input data from an excel spreadsheet a

2019-01-20 00:27发布

I need to create data driven unit tests for different APIs in karate framework. The various elements to be passed in the JSON payload should be taken as input from an excel file.

1条回答
贪生不怕死
2楼-- · 2019-01-20 00:46

A few points:

  • I recommend you look at Karate's built-in data-table capabilities, it is far more readable, integrates into your test-script and you won't need to depend on other software. Refer these examples: call-table.feature and dynamic-params.feature
  • Next I would recommend using JSON instead of an Excel or CSV file, it is natively supported by Karate: call-json-array.feature
  • Finally, if you really wanted to, you can call any Java code and if you return data in a Map / List form, it will be ready for Karate to use. This example shows how to read a database via 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.
查看更多
登录 后发表回答