'How do you parameterize the read function in karate

How do you parameterize the read function in karate? For example:

* def testcases = read("../TestCases/TestCases.csv")
* def wflowjson = '<wflowjson>'-- wflowjson is coming from TestCases.csv
* def expectedResponse = read(wflowjson)
* print 'expectedResponse--->' expectedResponse


Solution 1:[1]

There is no such thing as parameterizing a read of a JSON or CSV file.

But when variables are defined, they can get substituted within the file using embedded expressions: https://stackoverflow.com/a/60434757/143475

Note that you can use variables for the file-name when you read for example:

* def myJson = read(someVar + '/foo.json')

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peter Thomas