OR clause in Gatling check verifier

31 views
Skip to first unread message

megha pandit

unread,
Sep 2, 2015, 2:39:16 PM9/2/15
to Gatling User Group
Hi,

Currently my script implements the check as below to verify JSON response

.check(regex("\"status\":1").exists)


Now one of the requests return status 1 or status 6 depending on the work flow.

Both are valid responses.


Is there a way to implement a check with OR clause and declare it a pass if either value(s) is found.


Regards,

Megha

 

Alex R.

unread,
Sep 3, 2015, 12:52:20 AM9/3/15
to Gatling User Group
Hi Megha,

Looking at your regex I assume that you checking some json response.
You can use JsonPath expression and save result to session (see http://gatling.io/docs/2.1.7/http/http_check.html):

.check(jsonPath("$.status").exists.saveAs("status"))

Then you can use session api to access to the "status" variable and make doIfOrElse or switch.

doIf (session => session.get("status").as[String], "1") {
 ....
}


Thanks,
Alex.

megha pandit

unread,
Sep 3, 2015, 10:41:46 AM9/3/15
to Gatling User Group
Thanks Alex for the idea of using JsonPath expression.
Changed the check to the following and it works like a charm!

.check(jsonPath("$.status").in("1","6"))


Regards,

Megha

Reply all
Reply to author
Forward
0 new messages