Json 在空手道DSL中,如何将替换文本用于其他数据类型,如int、float、Big等。?
我在github上找到了下面的示例Json 在空手道DSL中,如何将替换文本用于其他数据类型,如int、float、Big等。?,json,rest,cucumber,karate,Json,Rest,Cucumber,Karate,我在github上找到了下面的示例 def text='你好,再见' 替换文本 |令牌|值| |一|“残忍”| |两个“好”| match text==“你好,残酷世界,再见” 如果我要替换的值只能接受整数或其他数据类型,该怎么办?比如说, 替换文本 |令牌|值| |小时| 90| |价格| 123.45| |数量| 99999999| 我无法将令牌放入另一个文件中,因为json验证器不喜欢没有双引号的。有什么建议吗 Replace用于文本而不是JSON,请仔细阅读文档。首先,编号和更换
- def text='你好,再见'
- 替换文本 |令牌|值| |一|“残忍”| |两个“好”|
- match text==“你好,残酷世界,再见”
- 替换文本 |令牌|值| |小时| 90| |价格| 123.45| |数量| 99999999|
我无法将令牌放入另一个文件中,因为json验证器不喜欢没有双引号的。有什么建议吗 Replace用于文本而不是JSON,请仔细阅读文档。首先,编号和更换没有问题:
* def text = 'hello <name> how many <hours>'
* replace text
| token | value |
| name | 'John' |
| hours | 200 |
* match text == 'hello John how many 200'
请注意,即使省略了第一行,上述方法也会起作用。另一种替代JSON中值的方法是使用嵌入表达式,请参阅文档
* def json = { hello: '', hours: null }
* set json
| path | value |
| hello | 'John' |
| hours | 200 |
* match json == { hello: 'John', hours: 200 }