gatling v3, why System.currentTimeMillis().toString always return same value?

I knew there should be simple solution to this, however it’s not working for me in following conditions:

  1. repeat the Object that has a POST with dynamic body contains the unique System.currentTimeMillis()
    EVERY Time
  2. I tried direct invoke System.currentTimeMillis() in body, as well as define it as a method, or as another object

Appreciate any quick and simple solution
Thank you
Jack

the Gatling DSL is a series of builders that get executed at startup - hence all executions of your POST having the same value.
You need to set a session variable with the current time and use that in the body

How about you try something like this.

val scn = Scenario(“Current Time Scenario)
.repeat(10){
exec(session => {
session.set(“currentTime”, System.currentTimeMillis())
})
.exec(http(“ABC”)
.body(StringBody(”""${currentTime}"""))
.check(status.is(200)))
}