[英]Check value extracted with JSONPath and compare with regex using Gatling
有没有办法在Gatling做这样的事情:
scenario("Check UUID with regex")
.exec(http("Get UUID")
.get("http://myapp/api/v1/goal/a24e210c-0fc1-44a0-a5ca-9bd5d8d71916")
.check(jsonPath("$.id").is(regex("[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}")))
基本上我想对check JSONPath构造中返回的内容应用正则表达式比较。
和平了!
PS我知道我可以这样做: .check(regex("\\"id\\": \\"[0-9a-fA-F]{8}\\\\-[0-9a-fA-F]{4}\\\\-[0-9a-fA-F]{4}\\\\-[0-9a-fA-F]{4}\\\\-[0-9a-fA-F]{12}\\"").exists)
没有什么比你描述的更好,但是你可以使用变换来伪造它
.check(jsonPath("$.id")
.find
.transform(id => "[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}".r
.findFirstMatchIn(id) match {
case Some(value) => true
case None => false
}
).is(true)
但如果直接的正则表达式检查有效...我会继续这样做
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.