I need to upload a file to a specific endpoint, but I have a couple of different files for each different environment I'm testing the endpoint in. I have a file structure similar to this:
src
|
+-- java
| |
| +-- test.feature
|
+-- resources
| |
| +-- dev
| | |
| | +-- file.txt
| |
| +-- qa
| |
+ +-- file.txt
So I thought to assign the environment to a variable and use it to indicate the file path in the multipart-file step:
And multipart file file = { read: "classpath:#(environment)/file.txt", filename: 'file.txt', contentType: 'multipart/form-data' }
However, when I tried this, Karate didn't seem to actually replace #(environment) with the proper variable, as I expected it to:
org.graalvm.polyglot.PolyglotException: not found: #(environment)/file.txt
I also tried to use the Karate replace functionality, but that failed for me as well.
Is there any other way to specify a file path like this in Karate?