Can we pass the excel file or .csv file as a table

2019-07-29 12:58发布

问题:

In Karate, we are parameterizing with the below values. Do we have any option of passing the table as external file in karate.

And table tablename
     | name | age | id |
     | abc  | 02  | 01 |
     | def  | 03  | 02 |

And def values = { "name": '(#name)', "age": '(#age)', "id" : '(#id)' }

Expecting below in karate framework.

And table <tablefile.xls>
And def values = { "name": '(#name)', "age": '(#age)', "id" : '(#id)' }

回答1:

There are multiple ways, the most recommended is to use JSON for maintaining test data.

Please take a look at this answer for details: https://stackoverflow.com/a/49031155/143475

EDIT: Since OP is insisting on Excel, please refer to this other answer where this is explained in detail: https://stackoverflow.com/a/47954946/143475

If I were you I would NOT use Excel and at least use CSV. In my opinion table or set is far easier to maintain than Excel and you can do it as part of your test feature file itself.



标签: karate