如何在输入json文件中参数化字符串以及变量名

时间:2019-08-26 09:14:04

标签: karate

def userName ='ABC'

def input json = {
    "integration": {
        "serviceData": {
            "integrationService": {
                "name": "fld_<tenantID>_stage00.integrations:<integrationName>"
            },
            "gitComments": "Commit made by: ABC"

        }
    }
} 

在上面的json中,我需要参数化用户名'ABC'

如果我发送 “ gitComments”:“#(用户名)”

正在检查'ABC'很好 但是我需要在字符串“ Commit made by:”之前加上前缀,然后在输入的json中添加#(userName)。

预先感谢

1 个答案:

答案 0 :(得分:2)

我想您永远不会阅读文档。正确:) https://github.com/intuit/karate#rules-for-embedded-expressions

* def gitComments = 'Commit made by: ' + userName
* def json = { gitComments: '#(gitComments)' }