我试图断言键不在JSON响应中。这是响应
{
"_type": "UserAccount",
"accountName": "Account_Name",
"accountType": "regular",
"whiteList": true,
"sfAccountId": "1",
"preferredLanguage": "english",
"imageSize": "highRes",
"_id": "775a8451-6a07-42da-a199-fe98f44bdc06"
}
我根据文档空手道#null and-notpresent尝试了这两个步骤,彼得·托马斯(Peter Thomas)的答案
And match response.appClientId == '#notpresent'
And match response == {appClientId:'#notpresent'}
但是,这是我一直在上面的第一步
的错误com.jayway.jsonpath.PathNotFoundException: No results for path: $['appClientId']
和第二步
com.intuit.karate.KarateException: path: $, actual
预先感谢
也许您的版本已过时,以下版本对我有0.9.1:
* def response =
"""
{
"_type": "UserAccount",
"accountName": "Account_Name",
"accountType": "regular",
"whiteList": true,
"sfAccountId": "1",
"preferredLanguage": "english",
"imageSize": "highRes",
"_id": "775a8451-6a07-42da-a199-fe98f44bdc06"
}
"""
* match response.appClientId == '#notpresent'
* match response contains { appClientId: '#notpresent' }