Using templates

Hi,

I am trying to use templates for one of my scenarios. My template looks like this:

“offerId”: “<%= offerId %>”,

“description”: “This is a load test”

where offerId is a random number (not coming from any file). and my scenario looks like this:

val uId = util.generateNumber()

val scn = scenario(name)

.exec(session => session.set(“offerId”, uId))

.exec(

http(name)

.put(url)

.body(ELFileBody(“OfferTemplate.ssp”))

.headers(headers)

.check(status is 200)

I have couple of questions in this regard. 1. It is not replacing <%= offerId %> with a dynamic value. Anything wrong here? 2. I have not specified any feed method here. IS this okay? If not, I am not sure what I need to specify in this case. 3. I am testing my rest endpoint here and my intention is to send file contents as payload. Do I need to enclose it in “payload”: [ …] ?

Thanks.

You made uId a val, so it’s just a static value and util.generateNumber() is only called once, when loading the Simulation.

Try .exec(session => session.set(“offerId”, util.generateNumber()))

Thanks Stephane.