Search code examples
scalaperformance-testingload-testinggatling

How to extract List attribute from session in Gatling?


In Gatling 2.1 I'm saving bunch of Ids like this:

.findAll.saveAs("ids"))

This adds list of Ids in session:

ids -> List(0, 1, 2, 3)

I'd like to have this list as regular Scala variable.

In case of Strings it works fine:

.exec(session => {      
    val mystring= session("SomeString").as[String]
    session
  })

How do I make this work for a List?


Solution

  • Just cast into a List instead of a String.

    Assuming you really have a List[Int] as in your sample, and not a List[String]:

    .exec { session =>  
      val mystring= session("SomeString").as[List[Int]]
      session
    }