PloniStacker
PloniStacker

Reputation: 666

Gatling how to create a list and pass it to the session?

So I'd like to create a list of random numbers from -7 to 7 and then iterate through these numbers. So I am running the following in order to create the list and save it in the session:

.exec(session => {session.set("randomDays", Random.shuffle(-7 to 7 toList))})

But then when I try to iterate through the list with:

.foreach("randomDays", "counter")

I am getting getting the following error message:

" Condition evaluation crashed with message 'Can't cast value randomDays of type class java.lang.String into interface scala.collection.Seq'"

When I am looking at the session values I see what looks like a list of random values as expected (see attached screenshot). What am I getting wrong here?

enter image description here

Upvotes: 0

Views: 1334

Answers (1)

PloniStacker
PloniStacker

Reputation: 666

If anyone is interested, what I ended up doing is creating a random days val in my test class and fetched a different day using a repeat counter.

   .repeat(14, "counter") {
      exec(session =>{session.set("randomDay",randomDays(session("counter").as[Int]))})

I would still be very happy to understand what I got wrong with my initial attempt :)

Upvotes: 1

Related Questions