gpt4 book ai didi

scala - Gatling - 使用 JsonPath 检查多个值

转载 作者:行者123 更新时间:2023-11-28 19:57:59 24 4
gpt4 key购买 nike

我使用的是 Gatling 2.1.7,但找不到使用 JsonPath 检查多个值的方法。

假设我有这个 Json:

{
"messageTyp": "wsopen",
"userId": "1"
}

我确实需要检查这两个值。很容易检查值:

.check(wsAwait.within(2).expect(1).jsonPath("$..messageType").is("wsopen"))

但是因为这个测试是在一个“feeder”循环中运行的,所以有很多“wsopen”消息,异步返回。我需要检查每个用户是否都收到了一条“wsopen”消息。

我需要类似的东西

.check(wsAwait.within(2).expect(1).jsonPath("$..messageType").is("wsopen").and.jsonPath("$..userId").is("${userid}")) // won't compile

有人提示吗?

最佳答案

您可以使用 JSONPath 来完成直接:

jsonPath("$[?(@.messageTyp=='wsopen' && @.userId=='1')]").exists

关于scala - Gatling - 使用 JsonPath 检查多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35859608/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com