【发布时间】:2023-03-21 09:40:02
【问题描述】:
我在 Gatling 有一个场景,我想检查响应正文值是否映射到错误字符串。响应是 400:
{"error": "ERROR_1"}
检查失败并出现编译错误:
http("Some Request")
.put("/endpoint")
.asJson
.check(jsonPath("$.error") == "ERROR_1")
.check(status.is(400))
还尝试将错误保存为变量
.check(jsonPath("$.error").saveAs("error"))
.check("${error}" == "ERROR_1")
并意识到.check("${error}".is("ERROR_1")) 也不起作用,因为 .is 仅适用于整数。 gatling 文档也没有过多解释表达式 https://gatling.io/docs/current/http/http_check#validating
有什么想法吗?
【问题讨论】: