在使用jsonPath (或任何其他匹配器)时,我无法执行检查。
当使用message时,我可以在会话中保存整个JSON消息
.check(wsAwait
.within(6 seconds)
.until(1)
.message.exists
//.jsonpJsonPath("$.data").exists
.saveAs("CID"))在接下来的场景中,我可以打印整个消息
{"event":"ConversationCreated",
"data":"{"conversationId":"0e21f93d-6b0c-441f-a01d-8b0aa4e14769",
"customerInfo":null,"deviceInfo":null}"}但是当使用pathJson matcher时,我的支票超时
.check(wsAwait
.within(6 seconds)
.until(1)
// .message.exists
.jsonpJsonPath("$.data").exists
.saveAs("CID"))运行时会产生
...
12:09:32.248 [ERROR] i.g.c.a.b.SessionHookBuilder$$anon$1 - 'hook-2' crashed with 'java.util.NoSuchElementException: key not found: CID', forwarding to the next one
...
---- Errors --------------------------------------------------------------------
> Check failed: Timeout 1 (100,0%)发布于 2017-12-22 09:11:32
我设法让它“发挥作用”。
问题是在JSON中缺少托管JSON。
当您通过sse发送一些数据时,您的客户端将同时接收数据和事件类型。而Gatling将其作为Json对象提供。如果您发送的数据也是Json Gatling,那么Json Gatling将把它作为简单的字符串传递,而不进行任何修改,这会造成不正确的Json。
实际上:
{"event":"ConversationCreated",
"data":"{"conversationId":"0e21f93d-6b0c-441f-a01d-8b0aa4e19",
"customerInfo":null,"deviceInfo":null}"}适当的:
{"event":"ConversationCreated",
"data":"{\"conversationI\d":\"0e21f93d-6b0c-441f-a01d-8b0aa4e19\",
\"customerInfo\":null,\"deviceInfo\":null}\"}或者,与其将message保存在Json中,不如将其保留为对象:
case class Message(event: String, data: String)https://stackoverflow.com/questions/47812036
复制相似问题