Reputation: 1316
I am using Gatling 3.6.1.
I would like to attach gatling param to the request in order to force getting the value NOT from the cache. I would like it to be configurable, in a way to attach it when I want to force thing not to use cache and in other times I would like to use cache so I wouldn't attach the param or at least the unique value to it.
This is what I tried:
http("ProductReferencesPDP")
.get(path + "products/${product_code}/references?currentPage=1&pageSize=25&lang=de").queryParam("gatling", session => System.currentTimeMillis().toString)
.check(jsonPath("$..numberOfPages").exists)
And it attaches the gatling param always. But how can I make it optional, meaning someting like this:
http("ProductReferencesPDP")
.get(path + "products/${product_code}/references?currentPage=1&pageSize=25&lang=de").queryParam("gatling", if withCache "" else session => System.currentTimeMillis().toString)
.check(jsonPath("$..numberOfPages").exists)
But it doesn't work like this. I cannot access the session in the if clause or in u custom function for that matter.
Thanks!
Upvotes: 0
Views: 248
Reputation: 6623
.queryParam("gatling", if withCache "" else session => System.currentTimeMillis().toString)
Your if statement returns either a String or a Function. This can't possibly work. Try
.queryParam("gatling", session => if (withCache) "" else System.currentTimeMillis().toString)
Upvotes: 1