I am using session.userId to parametrize my test requests like this:
exec(http("get request")
.get((s:Session) => "somebaseUrl/" + s.userId.toString ))
Is it possible to get sesion userId differently, so my request addresses are more DRY, eg I won't have to use lambda?
I tried using gatling DSL:
exec(http("get request")
.get("somebaseUrl/${userId}")
but then I get: No attribute named 'userId' is defined
error
I could just calculate some random id to my tests, but why when gatling already does this.
Only solution that I came up with is saving userId to some different attribute like this:
exec((s:Session) => s.set("user_id",s.userId)),
exec(http("test").get("${user_id}"))
but that doesn't seem right, and you have to make sure to call the set before all other requests.
The userId is some internal details. Gatling Expression language only exposes Session attributes, ie the attributes Map content.
Either use the first way you described, with a function, or don't use Gatling internals and set your own UUID attribute (feeder, exec(function), etc).