Reputation: 420
I have simple scenario when I'm creating some object by sending ElFileBody
based json with post
method. I would like to pass to this file some unique id, that after execution of scenario all objects created with this test would have exactly te same id.
I was trying with
exec(session ->
session.set("testExecutionId", java.util.UUID.randomUUID.toString)
);
but this is executed a every run and each execution get own testExecutionId. Can someone tell me is it posibble to do such thing, or maybe there is already something like this out of a box?
Upvotes: 0
Views: 938
Reputation: 2545
At first please use feed
instead exec
with session.set
- this is a more correct way.
The nuance in your code is that the method java.util.UUID.randomUUID.toString
is called every time. We can solve this once by initializing the id via val
variable.
val uuid = java.util.UUID.randomUUID.toString
val testExecutionFeeder = Iterator.continually(Map("testExecutionId" -> uuid))
And then add to your scenario:
scenario(...)
.feed(testExecutionFeeder)
...
Upvotes: 3