我最近进行了一次 1 关测试,其中有 2 个字符串作为可选响应值,但是当尝试与“##”快捷方式匹配时,它失败了。遵循here
发现的见解测试中的匹配
* match $.txnId == txnIdCheck
* match $.timestamp == timestampCheck
* match $.message == '##("SUCCESS")'
* match $.code == '##("An error occurred while processing hotlisted status")'
* match $.hotListedStatus == '#boolean'
回应
{
"txnId": "b4415a7a-ced3-4553-92a5-bc0c8eafc388",
"timestamp": "2024-01-05T18:40:40.248Z",
"code": "An error occurred while processing hotlisted status",
"hotListedStatus": false
}
错误
* match $.message == '##("SUCCESS")'
match failed: EQUALS
$ | actual path does not exist (STRING:STRING)
'#notpresent'
'SUCCESS'
空手道的设计原理如下:
* def response =
"""
{
"txnId": "b4415a7a-ced3-4553-92a5-bc0c8eafc388",
"timestamp": "2024-01-05T18:40:40.248Z",
"code": "An error occurred while processing hotlisted status",
"hotListedStatus": false
}
"""
* match response ==
"""
{
"txnId": "#string",
"timestamp": "#string",
"message": "##string",
"code": "#string",
"hotListedStatus": "#boolean"
}
"""
这也有效:
* def expected =
"""
({
"txnId": "#string",
"timestamp": "#string",
"message": "##('foo')",
"code": "#string",
"hotListedStatus": "#boolean"
})
"""
* match response == expected