scalaload-testinggatling

How to write a value from the response to a file in Gatling?


I have a script which creates new referenceId each time its executed. I used

.check(regex("orders.(.*?)\"").saveAs("referenceId")))

to extract the referenceId. Now, how can I write/append it to a file without impacting the script even if I run it as a load test?


Solution

  • I used session in .exec to write my value into a file. Here it is:

    .exec( session => {
                    scala.tools.nsc.io.File("../user-files/data/refenceId.csv").appendAll(session("refenceId").as[String]+"\n")
                    session}
          )