简体   繁体   中英

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?

在此处输入图片说明

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM