如何在每个方案的XML中设置变量
我在下面设置了此XML:
* def Request =
"""
<new1:Account>
<shar:PaidMode>#(PaidMode)</shar:PaidMode>
<shar:BillCycleCredit>#(BillCycleCredit)</shar:BillCycleCredit>
<shar:CreditCtrlMode>#(CreditCtrlMode)</shar:CreditCtrlMode>
<new1:BillCycleType>#(BillCycleType)</new1:BillCycleType>
</new1:Account>
"""
测试如下:
Scenario: Create first subscriber
* def PaidMode = '0'
And request Request
When method Post
Then status 200
* print Request
但是我似乎无法将此付费模式归于0 :(我已经阅读了
变量你peter!)
https://github.com/karatebs/karatelabs/karate#embedded-eppressions
简单,我敢肯定,这对我来说并不明显
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一切对我来说都很好。但是:在声明XML变量“正文”之前,请确保您设置变量“付费模式”!也许这就是你错过的。
尝试此示例,该示例应该有效:
现在,如果您确实需要拥有XML“ pre set”,则可以使用
set
关键字进行这样的更新:一个技巧是
读取
来自文件的XML,因此您将获得重新使用的好处,您似乎要追求:Everything looks fine to me. But: make sure you set the variable 'paidMode' before you declare the xml variable 'body' ! Maybe that's what you missed.
Try this example, which should work:
Now, if you really have a need to have the XML "pre set" you can use the
set
keyword to make an update like this:One trick is to
read
the XML from a file, so you get the benefit of re-use which you seem to be going for: