Is the body evaluated multiple times ?
Because I use a method randomPayload and the randomness doesn’t work
val scn = scenario("BasicSimulation")
.during(10 seconds)(
pace(1 seconds).
exec(http("request").post("…").body(StringBody(randomPayload)))
)
During the construction of the scenario, your function randomPayload is being called exactly once, and the return value (which I presume is a string) is being fed into StringBody.
If you want it to do it multiple times, you have to have randomPayload return a function that returns a string. Or more precisely, the same type as what StringBody expects when it receives an Expression. Define your randomPayload something like this:
def randomPayload : ( Session => Validation[Session] ) = session => { // existing definition }
Then, it will get run every time the scenario encounters it.
Thanks a lot, that has fixed !
Small typo, it’s Validation[String]
Oh, yes, I was copying from a different piece of code that existed to inject things into the session.