Home > database >  Gatling 3.8.4 problems when trying to switch from expressions ${} to #{}
Gatling 3.8.4 problems when trying to switch from expressions ${} to #{}

Time:12-17

I have upgraded my project from Gatling 3.3.1 version to Gatling 3.8.4 version, my question specifically refers to Expression language I have an old version scala script created where there are several variables in the old style pattern "${}" so I want to change that into the new pattern "#{}"

this is an example of what I am trying to achieve:

private def requestAndSaveSample(tokenVal: String) = {
http(s"logging user at: ${"/o/token"}")
.post(myApiUrl   "/o/token")
.headers(Map(("Content-Type", "application/x-www-form-urlencoded")))

So when I try to change into #{"/o/token"}"). then I get some errors that I have been trying to solve, but no luck yet.

and also another question is related to handling these expressions at the endpoints, for example here:

http(s"List someSample by users")
.get(s"/v2/someSample/$entityId/userAssert")

when I change that to use the new pattern like this:

.get("/v2/someSample/#{entityId}/userAssert")

I get an error that says that the value does not exist. Do you have any clue on this or any recommendation about some examples that provide a bit more information regarding the EL Gatling?

Thanks in advance for your time.

CodePudding user response:

You're confusing:

  • s"${...}" with the prepended s which is Scala String interpolation
  • "${...}" without the prepended s, which is the deprecated Gatling Expression Language syntax, now replaced with #{...}

You must change the former, only the latter.

  • Related