Karate 空手道场景大纲-基于JSON数组索引大小创建动态示例表

Karate 空手道场景大纲-基于JSON数组索引大小创建动态示例表,karate,Karate,在这里,我想澄清一下如何为动态JSON索引大小创建动态示例表 我的JSON看起来像 Env-Dev-2服务器 "response": { "abc": [{ "status": "pass" . . }, { "status": "pass" . . } ]

在这里,我想澄清一下如何为动态JSON索引大小创建动态示例表

我的JSON看起来像

Env-Dev-2服务器

"response": {
    "abc": [{
            "status": "pass"
                .
                .
        },
        {
            "status": "pass"
                .
                .
        }
    ]
}
{
    "response": {
        "abc": [{
                "status": "pass"
            },
            {
                "status": "pass"
            },
            {
                "status": "pass"
            }
        ]
    }
}
Env-Uat-3台服务器

"response": {
    "abc": [{
            "status": "pass"
                .
                .
        },
        {
            "status": "pass"
                .
                .
        }
    ]
}
{
    "response": {
        "abc": [{
                "status": "pass"
            },
            {
                "status": "pass"
            },
            {
                "status": "pass"
            }
        ]
    }
}
我的场景大纲看起来像

Scenario Outline: validating .....

When def result = callonce read('featurefilename@tagname')

Then print result

And print <status>

And print ...

And match ....

Examples:

|result.response.abc|

场景大纲:验证。。。。。
当def result=callonce read('featurefilename@tagname')
然后打印结果
和打印
并打印。。。
和匹配。。。。
示例:
|result.response.abc|
上述错误:

1) *动态表达式计算失败:result.response.abc

2) com.intuit.karate.karateExpresion:----javascript求值失败result.response.abc,ReferenceError:第1行中未定义“结果”

注意-如果我在def result=callonce read('featurefilename@tagname“)到后台它按预期工作,但由于其他因素,我无法在功能文件中使用后台


提前感谢

您可以利用空手道中的功能,而不是在表中提供索引

在这种情况下,您可以将变量作为输入传递给
示例
。如果上面提供的JSON来自变量
result
,那么

Examples:
 | result.response.abc |

有关更多细节,请参阅文档

感谢您提供的信息,它将收到失败的错误消息-“*动态表达式计算失败:response.abc”。1) 即使是一个步骤也没有执行。-参考错误是-“响应”在第1行不是a(2)让我也给你我的场景。当def result=调用一次读取(featurename@tagname)然后打印。。。并打印…Sry您的场景不清楚。请用情景更新您的问题,也请参考我的更新答案更新我的问题并详细解释,如果您需要更多,请让我知道information@chandrashekar请遵循以下流程: