如何在空手道多部分文件中动态指定文件路径?
对每个不同的环境都有几个不同的文件。
src
|
+-- java
| |
| +-- test.feature
|
+-- resources
| |
| +-- dev
| | |
| | +-- file.txt
| |
| +-- qa
| |
+ +-- file.txt
我需要将文件上传到特定的端点,但是我 并使用它来指示多部分文件步骤中的文件路径:
And multipart file file = { read: "classpath:#(environment)/file.txt", filename: 'file.txt', contentType: 'multipart/form-data' }
但是,当我尝试此操作时,空手道似乎并没有真正替换##(环境)
使用适当的变量,正如我所期望的那样到:
org.graalvm.polyglot.PolyglotException: not found: #(environment)/file.txt
我还尝试使用空手道替换
功能,但这也失败了。
还有其他方法可以在空手道中指定这样的文件路径吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请阅读以下内容: https://github.com/karatebs/karate #karatebs/karate#rules-wrules--wrules--com- for-embedded-expressions
所以请尝试以下操作:
Please read this: https://github.com/karatelabs/karate#rules-for-embedded-expressions
So try this: