在空手道中构建动态url并将json输出写入文件 [英] building dynamic urls in Karate and writing json output to a file
问题描述
如何在空手道功能文件中建立动态网址?我尝试过类似的方法,但是没有用.
How to build dynamic urls in Karate feature file? I tried something like this and didn't work.
Feature: PMS API Status Check
Background:
* url baseUrl
* def spirit = 'SANRS'
Scenario: Get guest details.
Given path "'#(spirit)'/reservation/all"
Url并未评估SANRS,而是本着其精神.另外,如何更改将json响应写入文件.我看到我们可以使用read(fileName)读取文件,但没有看到用于写入文件的示例.
Url is not evaluating to SANRS and goes as spirit. Also how do I change write the json response to a file. I see we can read the file using read(fileName) but did not see examples for writing to a file.
推荐答案
'#(foo)'
表示法仅适用于JSON,XML或match语句的右侧.
The '#(foo)'
notation applies only to JSON, XML or the right-hand-side of a match statement.
请像正常的JS表达式一样使用它:
Please use it like a normal JS expression:
Given path spirit, 'reservation', 'all'
请务必查看文档和示例!
Please do look at the documentation and examples !
是的,没有写文件的例子,因为不建议在测试中使用.如果您确实要执行此操作-只需编写自定义Java或JavaScript函数,请参阅文档调用Java".
Yes, there is no example for writing to a file, because this is not recommended for tests. If you really want to do this - just write a custom Java or JavaScript function, refer to the docs for "Calling Java".
这篇关于在空手道中构建动态url并将json输出写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!