Gatling checkIf语法

时间:2018-06-14 23:53:42

标签: scala gatling scala-gatling

遗留应用程序具有以下工作加特林测试

private val getUserByTuid = scenario("GetActiveUserInfoWrapper")
    .feed(users.toArray.circular)
    .exec(
      http("GET /v1/foo/{id}")
        .get("/v1/foo/${id}")
        .header("Content-Type", "application/json")
        .header("User-Agent", "gatling")
        .check(status is 200)
        .check(jsonPath("$..ID") exists)
    )

我需要更改它,使得状态为200,在这种情况下,它检查jsonnode ID是否存在(就像上面一样),或状态是401,在这种情况下,它检查jsonnode描述是否存在。任何其他状态都会导致失败。

这是我到目前为止所做的,但它看起来并没有按预期工作,因为Gatling认为所有响应都失败了,即使是ID为200且带有描述的401也是如此。

private val getUserByTuid = scenario("GetActiveUserInfoWrapper")
    .feed(users.toArray.circular)
    .exec(
      http("GET /v1/foo/{id}")
        .get("/v1/foo/${id}")
        .header("Content-Type", "application/json")
        .header("User-Agent", "gatling")
        .check(checkIf((response: Response, session: Session) => response.status.get.getStatusCode == 200)(jsonPath("$..ID") exists))
        .check(checkIf((response: Response, session: Session) => response.status.get.getStatusCode == 401)(jsonPath("$..Description") exists))
    )

我查看了文档并在网上搜索过,但我们无法找到实现我想要的正确方法,因此请在这里询问。

0 个答案:

没有答案
相关问题